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: Christoph Hellwig <hch@lst.de>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
This commit is contained in:
Chaitanya Kulkarni 2020-01-30 10:29:33 -08:00 committed by Keith Busch
parent 013b7ebe5a
commit d3a9b0cadf
1 changed files with 5 additions and 2 deletions

View File

@ -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,
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);
sscanf(page, "%llx\n", &subsys->serial);
to_subsys(item)->serial = serial;
up_write(&nvmet_config_sem);
return count;