mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: green@linuxhacker.ru
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	devel@driverdev.osuosl.org,
	Andreas Dilger <andreas.dilger@intel.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Oleg Drokin <green@linuxhacker.ru>
Subject: [PATCH 4/4] staging/lustre/libcfs: Fix kstrtouint return value check fix
Date: Mon, 13 Jul 2015 23:17:57 -0400	[thread overview]
Message-ID: <1436843877-28258-5-git-send-email-green@linuxhacker.ru> (raw)
In-Reply-To: <1436843877-28258-1-git-send-email-green@linuxhacker.ru>

From: Oleg Drokin <green@linuxhacker.ru>

Apparently kstrtouint could return not just -EINVAL, but also -ERANGE,
so make sure we just check the return value for something negative.

Noticed by Dan Carpenter <dan.carpenter@oracle.com>

Signed-off-by: Oleg Drokin <green@linuxhacker.ru>
---
 drivers/staging/lustre/lustre/libcfs/debug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/lustre/libcfs/debug.c b/drivers/staging/lustre/lustre/libcfs/debug.c
index 6346887..e93f556 100644
--- a/drivers/staging/lustre/lustre/libcfs/debug.c
+++ b/drivers/staging/lustre/lustre/libcfs/debug.c
@@ -185,7 +185,7 @@ static int param_set_uint_minmax(const char *val,
 	if (!val)
 		return -EINVAL;
 	ret = kstrtouint(val, 0, &num);
-	if (ret == -EINVAL || num < min || num > max)
+	if (ret < 0 || num < min || num > max)
 		return -EINVAL;
 	*((unsigned int *)kp->arg) = num;
 	return 0;
-- 
2.1.0


      parent reply	other threads:[~2015-07-14  3:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-14  3:17 [PATCH 0/4] Lustre: remaining bits of sysctl debugfs migration green
2015-07-14  3:17 ` [PATCH 1/4] staging/lustre/libcfs: get rid of debugfs/lnet/debug_mb green
2015-07-14  3:17 ` [PATCH 2/4] staging/lustre/libcfs: get rid of debugfs/lnet/console_{min,max}_delay_centisecs green
2015-07-14  3:17 ` [PATCH 3/4] staging/lustre/libcfs: remove unused portal_enter_debugger variable green
2015-07-14  3:17 ` green [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=1436843877-28258-5-git-send-email-green@linuxhacker.ru \
    --to=green@linuxhacker.ru \
    --cc=andreas.dilger@intel.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®