Skip to contentSkip to conversation

scsi: myrs: Add Mylex RAID controller (SCSI interface)

bug report Dan Carpenter 1 participant 1 message Aug 4, 2023 SCSI

lore
Share & tools
lore
#0 lore raw

Hello Hannes Reinecke,

The patch 77266186397c: "scsi: myrs: Add Mylex RAID controller (SCSI interface)" from Oct 17, 2018 (linux-next), leads to the following Smatch static checker warning:

drivers/scsi/myrs.c:1508 disable_enclosure_messages_store()
warn: no lower bound on 'value' rl='s32min-2'

drivers/scsi/myrs.c

    1494 static ssize_t disable_enclosure_messages_store(struct device *dev,
    1495                 struct device_attribute *attr, const char *buf, size_t count)
    1496 {
    1497         struct scsi_device *sdev = to_scsi_device(dev);
    1498         struct myrs_hba *cs = shost_priv(sdev->host);
    1499         int value, ret;
                 ^^^^^^^^^

    1500 
    1501         ret = kstrtoint(buf, 0, &value);
    1502         if (ret)
    1503                 return ret;
    1504 
    1505         if (value > 2)

Smatch is complaining about negative values of value. Why is 2 allowed when ->disable_enc_msg is a bool? We have a kstrtobool() function as well, btw.

This is from an unpublished Smatch check but I'm working on it to get it ready to release.

    1506                 return -EINVAL;
    1507 
--> 1508         cs->disable_enc_msg = value;
    1509         return count;
    1510 }

regards,
dan carpenter