Răsfoiți Sursa

regulator: core: use snprintf() instead of scnprintf()

When creating the link to the device sysfs entry, the regulator core
calls scnprintf() and then checks if the returned value is greater or
equal than the buffer size.

The former can never happen as scnprintf() returns the number of bytes
that were actually written to the buffer, not the bytes that *would*
have been written.

Use the right function in this case: snprintf().

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Bartosz Golaszewski 8 ani în urmă
părinte
comite
b7cd1b1386
1 a modificat fișierele cu 2 adăugiri și 2 ștergeri
  1. 2 2
      drivers/regulator/core.c

+ 2 - 2
drivers/regulator/core.c

@@ -1326,8 +1326,8 @@ static struct regulator *create_regulator(struct regulator_dev *rdev,
 		regulator->dev = dev;
 		regulator->dev = dev;
 
 
 		/* Add a link to the device sysfs entry */
 		/* Add a link to the device sysfs entry */
-		size = scnprintf(buf, REG_STR_SIZE, "%s-%s",
-				 dev->kobj.name, supply_name);
+		size = snprintf(buf, REG_STR_SIZE, "%s-%s",
+				dev->kobj.name, supply_name);
 		if (size >= REG_STR_SIZE)
 		if (size >= REG_STR_SIZE)
 			goto overflow_err;
 			goto overflow_err;