On 08/03/2016 07:25 PM, Bart Van Assche wrote: > On 08/03/2016 06:13 AM, Hannes Reinecke wrote: >> 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@xxxxxxxx> >> --- >> drivers/scsi/fcoe/fcoe_sysfs.c | 12 ++++++++++-- >> 1 file changed, 10 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/scsi/fcoe/fcoe_sysfs.c >> b/drivers/scsi/fcoe/fcoe_sysfs.c >> index 9e6baac..9cf3d56 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; > > Hello Hannes, > > Please use kstrtoint() or similar such that strings like "01" are parsed > correctly. > Yeah, I'll be redoing them; the store and show methods in that entire file could do with an overall simplification. Cheers, Hannes -- Dr. Hannes Reinecke Teamlead Storage & Networking hare@xxxxxxx +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg) -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html