kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] scsi: myrs: cleanup myrs_store_suppress_enclosure_messages()
@ 2018-02-20  9:45 Dan Carpenter
  0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2018-02-20  9:45 UTC (permalink / raw)
  To: kernel-janitors

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;

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2018-02-20  9:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-20  9:45 [PATCH 1/2] scsi: myrs: cleanup myrs_store_suppress_enclosure_messages() Dan Carpenter

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).