提交 5cc55126 编写于 作者: H Hannes Reinecke 提交者: Martin K. Petersen

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: NHannes Reinecke <hare@suse.com>
Acked-by: NJohannes Thumshirn <jth@kernel.org>
Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
上级 c216e876
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册