diff options
author | Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> | 2020-01-30 10:29:33 -0800 |
---|---|---|
committer | Keith Busch <kbusch@kernel.org> | 2020-03-04 09:09:08 -0800 |
commit | d3a9b0cadf8cea1746a6bf525d049198e705836a (patch) | |
tree | 6f82fbd26503ce4afbc9c7f1c809ac991a98300f /drivers/nvme/target | |
parent | 013b7ebe5a0d70e2a02fd225174595e79c591b3e (diff) |
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>
Diffstat (limited to 'drivers/nvme/target')
-rw-r--r-- | drivers/nvme/target/configfs.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/nvme/target/configfs.c b/drivers/nvme/target/configfs.c index 1654064deea5..7aa10788b7c8 100644 --- a/drivers/nvme/target/configfs.c +++ b/drivers/nvme/target/configfs.c @@ -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; |