diff options
author | Hannes Reinecke <hare@suse.de> | 2016-10-13 15:10:57 +0200 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2016-11-08 17:29:53 -0500 |
commit | 5cc5512690537fcfafd50a5941cdbdb9f4134308 (patch) | |
tree | 70007f24bbb133c2ad1ffac7494e81ee21a353f7 /drivers/scsi/fcoe | |
parent | c216e8762f96b6bddf043b5788094e0b698dd4b3 (diff) |
scsi: fcoe: catch invalid values for the 'enabled' attribute
The 'enabled' sysfs attribute only accepts the values '0' and '1',
so we should error out any other values.
Signed-off-by: Hannes Reinecke <hare@suse.com>
Acked-by: Johannes Thumshirn <jth@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi/fcoe')
-rw-r--r-- | drivers/scsi/fcoe/fcoe_sysfs.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/scsi/fcoe/fcoe_sysfs.c b/drivers/scsi/fcoe/fcoe_sysfs.c index 9e6baac18e76..9cf3d56296ab 100644 --- a/drivers/scsi/fcoe/fcoe_sysfs.c +++ b/drivers/scsi/fcoe/fcoe_sysfs.c @@ -335,16 +335,24 @@ static ssize_t store_ctlr_enabled(struct device *dev, const char *buf, size_t count) { struct fcoe_ctlr_device *ctlr = dev_to_ctlr(dev); + bool enabled; int rc; + if (*buf == '1') + enabled = true; + else if (*buf == '0') + enabled = false; + else + return -EINVAL; + switch (ctlr->enabled) { case FCOE_CTLR_ENABLED: - if (*buf == '1') + if (enabled) return count; ctlr->enabled = FCOE_CTLR_DISABLED; break; case FCOE_CTLR_DISABLED: - if (*buf == '0') + if (!enabled) return count; ctlr->enabled = FCOE_CTLR_ENABLED; break; |