On Thu, 7 Apr 2011 17:06:18 +0800 Liu Yuan <namei.unix@xxxxxxxxx> wrote: > From: Liu Yuan <tailai.ly@xxxxxxxxxx> > > It should check if strict_strtoul() succeeds.This > patch fixes it. > > Signed-off-by: Liu Yuan <tailai.ly@xxxxxxxxxx> > --- > 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); } _ -- To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html