All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] regulator: core: use snprintf() instead of scnprintf()
@ 2017-03-06 16:34 Bartosz Golaszewski
  2017-03-07 12:27 ` Applied "regulator: core: use snprintf() instead of scnprintf()" to the regulator tree Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Bartosz Golaszewski @ 2017-03-06 16:34 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown; +Cc: linux-kernel, Bartosz Golaszewski

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>
---
 drivers/regulator/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 53d4fc7..f20ad0a 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1326,8 +1326,8 @@ static struct regulator *create_regulator(struct regulator_dev *rdev,
 		regulator->dev = dev;
 
 		/* 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)
 			goto overflow_err;
 
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-03-07 12:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-06 16:34 [PATCH] regulator: core: use snprintf() instead of scnprintf() Bartosz Golaszewski
2017-03-07 12:27 ` Applied "regulator: core: use snprintf() instead of scnprintf()" to the regulator tree Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.