From: Dan Carpenter <dan.carpenter@oracle.com>
To: kernel-janitors@vger.kernel.org
Subject: [PATCH 1/2] scsi: myrs: cleanup myrs_store_suppress_enclosure_messages()
Date: Tue, 20 Feb 2018 09:45:35 +0000 [thread overview]
Message-ID: <20180220094535.GA22646@mwanda> (raw)
This code causes a static checker because we have an upper bound on
"value" but not a lower bound. In other words "value" can be s32min-2.
It's harmless but really it should just be bool.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/drivers/scsi/myrs.c b/drivers/scsi/myrs.c
index 3b87c6942a8e..eaa9d143a282 100644
--- a/drivers/scsi/myrs.c
+++ b/drivers/scsi/myrs.c
@@ -1590,15 +1590,12 @@ static ssize_t myrs_store_suppress_enclosure_messages(struct device *dev,
{
struct scsi_device *sdev = to_scsi_device(dev);
myrs_hba *cs = (myrs_hba *)sdev->host->hostdata;
- char tmpbuf[8];
- ssize_t len;
- int value;
+ bool value;
+ int ret;
- len = count > sizeof(tmpbuf) - 1 ? sizeof(tmpbuf) - 1 : count;
- strncpy(tmpbuf, buf, len);
- tmpbuf[len] = '\0';
- if (sscanf(tmpbuf, "%d", &value) != 1 || value > 2)
- return -EINVAL;
+ ret = kstrtobool(buf, &value);
+ if (ret)
+ return ret;
cs->disable_enc_msg = value;
return count;
reply other threads:[~2018-02-20 9:45 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20180220094535.GA22646@mwanda \
--to=dan.carpenter@oracle.com \
--cc=kernel-janitors@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