All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: linux-fbdev@vger.kernel.org
Subject: Re: [PATCH] drivers, video: Add a check for strict_strtoul()
Date: Tue, 12 Apr 2011 22:00:09 +0000	[thread overview]
Message-ID: <20110412150009.243f6089.akpm@linux-foundation.org> (raw)
In-Reply-To: <1302167178-9216-1-git-send-email-namei.unix@gmail.com>

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);
 }
_


      parent reply	other threads:[~2011-04-12 22:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110412150009.243f6089.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=linux-fbdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.