* [PATCH] regulator: core: fix constraints debug output
@ 2015-05-20 20:17 Stefan Wahren
2015-05-20 20:35 ` Joe Perches
0 siblings, 1 reply; 3+ messages in thread
From: Stefan Wahren @ 2015-05-20 20:17 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown; +Cc: linux-kernel, Stefan Wahren, stable
In the case uV_offset is greater than 0 the debug output before
is accidentally overwritten. So take care of the output count.
Fixes: bf5892a8167e ("regulator: Support voltage offsets to compensate for drops")
CC: <stable@vger.kernel.org>
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
drivers/regulator/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 443eaab..9afa3af 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -801,7 +801,7 @@ static void print_constraints(struct regulator_dev *rdev)
}
if (constraints->uV_offset)
- count += sprintf(buf, "%dmV offset ",
+ count += sprintf(buf + count, "%dmV offset ",
constraints->uV_offset / 1000);
if (constraints->min_uA && constraints->max_uA) {
--
1.7.9.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] regulator: core: fix constraints debug output
2015-05-20 20:17 [PATCH] regulator: core: fix constraints debug output Stefan Wahren
@ 2015-05-20 20:35 ` Joe Perches
2015-05-21 6:42 ` Stefan Wahren
0 siblings, 1 reply; 3+ messages in thread
From: Joe Perches @ 2015-05-20 20:35 UTC (permalink / raw)
To: Stefan Wahren; +Cc: Liam Girdwood, Mark Brown, linux-kernel, stable
On Wed, 2015-05-20 at 20:17 +0000, Stefan Wahren wrote:
> In the case uV_offset is greater than 0 the debug output before
> is accidentally overwritten. So take care of the output count.
If you are going to take care, please change all of these
sprintf calls to snprintf.
The buf array may not be big enough [80] to hold the longest
possible output string.
> diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
[]
> @@ -801,7 +801,7 @@ static void print_constraints(struct regulator_dev *rdev)
> }
>
> if (constraints->uV_offset)
> - count += sprintf(buf, "%dmV offset ",
> + count += sprintf(buf + count, "%dmV offset ",
> constraints->uV_offset / 1000);
>
> if (constraints->min_uA && constraints->max_uA) {
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] regulator: core: fix constraints debug output
2015-05-20 20:35 ` Joe Perches
@ 2015-05-21 6:42 ` Stefan Wahren
0 siblings, 0 replies; 3+ messages in thread
From: Stefan Wahren @ 2015-05-21 6:42 UTC (permalink / raw)
To: Joe Perches; +Cc: Liam Girdwood, linux-kernel, Mark Brown, stable
Hi Joe,
> Joe Perches <joe@perches.com> hat am 20. Mai 2015 um 22:35 geschrieben:
>
>
> On Wed, 2015-05-20 at 20:17 +0000, Stefan Wahren wrote:
> > In the case uV_offset is greater than 0 the debug output before
> > is accidentally overwritten. So take care of the output count.
>
> If you are going to take care, please change all of these
> sprintf calls to snprintf.
thanks for pointing out. I will create a second version.
But using scnprintf should be better here.
>
> The buf array may not be big enough [80] to hold the longest
> possible output string.
>
Stefan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-05-21 6:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-20 20:17 [PATCH] regulator: core: fix constraints debug output Stefan Wahren
2015-05-20 20:35 ` Joe Perches
2015-05-21 6:42 ` Stefan Wahren
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox