Commit d3a9b0ca authored by Chaitanya Kulkarni's avatar Chaitanya Kulkarni Committed by Keith Busch

nvmet: check sscanf value for subsys serial attr

For nvmet in configfs.c we check return values for all the sscanf()
calls. Add similar check into the nvmet_subsys_attr_serial_store().
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarSagi Grimberg <sagi@grimberg.me>
Signed-off-by: default avatarChaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Signed-off-by: default avatarKeith Busch <kbusch@kernel.org>
parent 013b7ebe
...@@ -849,10 +849,13 @@ static ssize_t nvmet_subsys_attr_serial_show(struct config_item *item, ...@@ -849,10 +849,13 @@ static ssize_t nvmet_subsys_attr_serial_show(struct config_item *item,
static ssize_t nvmet_subsys_attr_serial_store(struct config_item *item, static ssize_t nvmet_subsys_attr_serial_store(struct config_item *item,
const char *page, size_t count) const char *page, size_t count)
{ {
struct nvmet_subsys *subsys = to_subsys(item); u64 serial;
if (sscanf(page, "%llx\n", &serial) != 1)
return -EINVAL;
down_write(&nvmet_config_sem); down_write(&nvmet_config_sem);
sscanf(page, "%llx\n", &subsys->serial); to_subsys(item)->serial = serial;
up_write(&nvmet_config_sem); up_write(&nvmet_config_sem);
return count; return count;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment