* [PATCH] drivers, video: Add a check for strict_strtoul()
@ 2011-04-07 9:06 Liu Yuan
2011-04-07 9:57 ` Hennerich, Michael
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Liu Yuan @ 2011-04-07 9:06 UTC (permalink / raw)
To: linux-fbdev
From: Liu Yuan <tailai.ly@taobao.com>
It should check if strict_strtoul() succeeds.This
patch fixes it.
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
---
drivers/video/backlight/adp5520_bl.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/drivers/video/backlight/adp5520_bl.c b/drivers/video/backlight/adp5520_bl.c
index af31197..fdef632 100644
--- a/drivers/video/backlight/adp5520_bl.c
+++ b/drivers/video/backlight/adp5520_bl.c
@@ -212,7 +212,9 @@ static ssize_t adp5520_bl_daylight_max_store(struct device *dev,
{
struct adp5520_bl *data = dev_get_drvdata(dev);
- strict_strtoul(buf, 10, &data->cached_daylight_max);
+ if (strict_strtoul(buf, 10, &data->cached_daylight_max) < 0)
+ return -EINVAL;
+
return adp5520_store(dev, buf, count, ADP5520_DAYLIGHT_MAX);
}
static DEVICE_ATTR(daylight_max, 0664, adp5520_bl_daylight_max_show,
--
1.7.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* RE: [PATCH] drivers, video: Add a check for strict_strtoul()
2011-04-07 9:06 [PATCH] drivers, video: Add a check for strict_strtoul() Liu Yuan
@ 2011-04-07 9:57 ` Hennerich, Michael
2011-04-07 16:16 ` Paul Mundt
2011-04-12 22:00 ` Andrew Morton
2 siblings, 0 replies; 4+ messages in thread
From: Hennerich, Michael @ 2011-04-07 9:57 UTC (permalink / raw)
To: linux-fbdev
Liu Yuan wrote on 2011-04-07:
> From: Liu Yuan <tailai.ly@taobao.com>
>
> It should check if strict_strtoul() succeeds.This patch fixes it.
>
> Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
Acked-by: Michael Hennerich <michael.hennerich@analog.com>
> ---
> drivers/video/backlight/adp5520_bl.c | 4 +++-
> 1 files changed, 3 insertions(+), 1 deletions(-)
> diff --git a/drivers/video/backlight/adp5520_bl.c
> b/drivers/video/backlight/adp5520_bl.c index af31197..fdef632 100644 ---
> a/drivers/video/backlight/adp5520_bl.c +++
> b/drivers/video/backlight/adp5520_bl.c @@ -212,7 +212,9 @@ static
> ssize_t adp5520_bl_daylight_max_store(struct device *dev, {
> struct adp5520_bl *data = dev_get_drvdata(dev);
> - strict_strtoul(buf, 10, &data->cached_daylight_max);
> + if (strict_strtoul(buf, 10, &data->cached_daylight_max) < 0)
> + return -EINVAL;
> +
> return adp5520_store(dev, buf, count, ADP5520_DAYLIGHT_MAX); }
> static DEVICE_ATTR(daylight_max, 0664, adp5520_bl_daylight_max_show,
Greetings,
Michael
--
Analog Devices GmbH Wilhelm-Wagenfeld-Str. 6 80807 Muenchen
Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368; Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin, Margaret Seif
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] drivers, video: Add a check for strict_strtoul()
2011-04-07 9:06 [PATCH] drivers, video: Add a check for strict_strtoul() Liu Yuan
2011-04-07 9:57 ` Hennerich, Michael
@ 2011-04-07 16:16 ` Paul Mundt
2011-04-12 22:00 ` Andrew Morton
2 siblings, 0 replies; 4+ messages in thread
From: Paul Mundt @ 2011-04-07 16:16 UTC (permalink / raw)
To: linux-fbdev
(Adding akpm to Cc..)
On Thu, Apr 07, 2011 at 10:57:17AM +0100, Hennerich, Michael wrote:
> Liu Yuan wrote on 2011-04-07:
> > From: Liu Yuan <tailai.ly@taobao.com>
> >
> > It should check if strict_strtoul() succeeds.This patch fixes it.
> >
> > Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
>
> Acked-by: Michael Hennerich <michael.hennerich@analog.com>
>
> > ---
> > drivers/video/backlight/adp5520_bl.c | 4 +++-
> > 1 files changed, 3 insertions(+), 1 deletions(-)
> > diff --git a/drivers/video/backlight/adp5520_bl.c
> > b/drivers/video/backlight/adp5520_bl.c index af31197..fdef632 100644 ---
> > a/drivers/video/backlight/adp5520_bl.c +++
> > b/drivers/video/backlight/adp5520_bl.c @@ -212,7 +212,9 @@ static
> > ssize_t adp5520_bl_daylight_max_store(struct device *dev, {
> > struct adp5520_bl *data = dev_get_drvdata(dev);
> > - strict_strtoul(buf, 10, &data->cached_daylight_max);
> > + if (strict_strtoul(buf, 10, &data->cached_daylight_max) < 0)
> > + return -EINVAL;
> > +
> > return adp5520_store(dev, buf, count, ADP5520_DAYLIGHT_MAX); }
> > static DEVICE_ATTR(daylight_max, 0664, adp5520_bl_daylight_max_show,
>
> Greetings,
> Michael
>
> --
> Analog Devices GmbH Wilhelm-Wagenfeld-Str. 6 80807 Muenchen
> Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368; Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin, Margaret Seif
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] drivers, video: Add a check for strict_strtoul()
2011-04-07 9:06 [PATCH] drivers, video: Add a check for strict_strtoul() Liu Yuan
2011-04-07 9:57 ` Hennerich, Michael
2011-04-07 16:16 ` Paul Mundt
@ 2011-04-12 22:00 ` Andrew Morton
2 siblings, 0 replies; 4+ messages in thread
From: Andrew Morton @ 2011-04-12 22:00 UTC (permalink / raw)
To: linux-fbdev
On Thu, 7 Apr 2011 17:06:18 +0800
Liu Yuan <namei.unix@gmail.com> wrote:
> From: Liu Yuan <tailai.ly@taobao.com>
>
> It should check if strict_strtoul() succeeds.This
> patch fixes it.
>
> Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
> ---
> drivers/video/backlight/adp5520_bl.c | 4 +++-
> 1 files changed, 3 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/video/backlight/adp5520_bl.c b/drivers/video/backlight/adp5520_bl.c
> index af31197..fdef632 100644
> --- a/drivers/video/backlight/adp5520_bl.c
> +++ b/drivers/video/backlight/adp5520_bl.c
> @@ -212,7 +212,9 @@ static ssize_t adp5520_bl_daylight_max_store(struct device *dev,
> {
> struct adp5520_bl *data = dev_get_drvdata(dev);
>
> - strict_strtoul(buf, 10, &data->cached_daylight_max);
> + if (strict_strtoul(buf, 10, &data->cached_daylight_max) < 0)
> + return -EINVAL;
> +
> return adp5520_store(dev, buf, count, ADP5520_DAYLIGHT_MAX);
> }
It is better to propagate strict_strtoul()'s errno, rather than
overriding it:
--- a/drivers/video/backlight/adp5520_bl.c~drivers-video-backlight-adp5520_blc-check-strict_strtoul-return-value-fix
+++ a/drivers/video/backlight/adp5520_bl.c
@@ -211,9 +211,11 @@ static ssize_t adp5520_bl_daylight_max_s
const char *buf, size_t count)
{
struct adp5520_bl *data = dev_get_drvdata(dev);
+ int ret;
- if (strict_strtoul(buf, 10, &data->cached_daylight_max) < 0)
- return -EINVAL;
+ ret = strict_strtoul(buf, 10, &data->cached_daylight_max);
+ if (ret < 0)
+ return ret;
return adp5520_store(dev, buf, count, ADP5520_DAYLIGHT_MAX);
}
_
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-04-12 22:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-07 9:06 [PATCH] drivers, video: Add a check for strict_strtoul() Liu Yuan
2011-04-07 9:57 ` Hennerich, Michael
2011-04-07 16:16 ` Paul Mundt
2011-04-12 22:00 ` Andrew Morton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).