diff options
author | Chaitanya Kulkarni <kch@nvidia.com> | 2022-03-08 14:56:58 -0800 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2022-03-14 08:43:06 +0100 |
commit | 98152eb70fffad910ee7c511b110afe98f162fc5 (patch) | |
tree | 9fd422016936f38837ef6caff6323bbd22174ded /drivers | |
parent | 73d77c53ff342bfa23daedf4475cdd06618e447b (diff) | |
download | linux-rpi-98152eb70fffad910ee7c511b110afe98f162fc5.tar.gz linux-rpi-98152eb70fffad910ee7c511b110afe98f162fc5.tar.bz2 linux-rpi-98152eb70fffad910ee7c511b110afe98f162fc5.zip |
nvmet: use snprintf() with PAGE_SIZE in configfs
Instead of using sprintf, use snprintf with buffer size limited to
PAGE_SIZE just like what we have for the rest of the file.
Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/nvme/target/configfs.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/drivers/nvme/target/configfs.c b/drivers/nvme/target/configfs.c index 0f5c680c851a..ac801fa1641b 100644 --- a/drivers/nvme/target/configfs.c +++ b/drivers/nvme/target/configfs.c @@ -60,10 +60,11 @@ static ssize_t nvmet_addr_adrfam_show(struct config_item *item, char *page) for (i = 1; i < ARRAY_SIZE(nvmet_addr_family); i++) { if (nvmet_addr_family[i].type == adrfam) - return sprintf(page, "%s\n", nvmet_addr_family[i].name); + return snprintf(page, PAGE_SIZE, "%s\n", + nvmet_addr_family[i].name); } - return sprintf(page, "\n"); + return snprintf(page, PAGE_SIZE, "\n"); } static ssize_t nvmet_addr_adrfam_store(struct config_item *item, @@ -160,10 +161,11 @@ static ssize_t nvmet_addr_treq_show(struct config_item *item, char *page) for (i = 0; i < ARRAY_SIZE(nvmet_addr_treq); i++) { if (treq == nvmet_addr_treq[i].type) - return sprintf(page, "%s\n", nvmet_addr_treq[i].name); + return snprintf(page, PAGE_SIZE, "%s\n", + nvmet_addr_treq[i].name); } - return sprintf(page, "\n"); + return snprintf(page, PAGE_SIZE, "\n"); } static ssize_t nvmet_addr_treq_store(struct config_item *item, @@ -281,7 +283,8 @@ static ssize_t nvmet_addr_trtype_show(struct config_item *item, for (i = 0; i < ARRAY_SIZE(nvmet_transport); i++) { if (port->disc_addr.trtype == nvmet_transport[i].type) - return sprintf(page, "%s\n", nvmet_transport[i].name); + return snprintf(page, PAGE_SIZE, + "%s\n", nvmet_transport[i].name); } return sprintf(page, "\n"); |