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

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

The patch

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

has been applied to the regulator tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From b7cd1b1386ff46e60452ad1f16530645761ca7b8 Mon Sep 17 00:00:00 2001
From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Date: Mon, 6 Mar 2017 17:34:48 +0100
Subject: [PATCH] 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>
---
 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 53d4fc70dbd0..f20ad0a8fc38 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.11.0

^ 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.