CC: kbuild-all(a)lists.01.org TO: Denis Efremov CC: Julia Lawall CC: Keith Busch CC: Jens Axboe CC: Christoph Hellwig CC: Sagi Grimberg CC: linux-nvme(a)lists.infradead.org CC: linux-kernel(a)vger.kernel.org From: kernel test robot drivers/nvme/host/core.c:2671:8-16: WARNING: use scnprintf or sprintf drivers/nvme/host/core.c:3388:8-16: WARNING: use scnprintf or sprintf drivers/nvme/host/core.c:3378:8-16: WARNING: use scnprintf or sprintf drivers/nvme/host/core.c:3368:8-16: WARNING: use scnprintf or sprintf drivers/nvme/host/core.c:3335:8-16: WARNING: use scnprintf or sprintf From Documentation/filesystems/sysfs.txt: show() must not use snprintf() when formatting the value to be returned to user space. If you can guarantee that an overflow will never happen you can use sprintf() otherwise you must use scnprintf(). Generated by: scripts/coccinelle/api/device_attr_show.cocci Fixes: 988676da8375 ("coccinelle: api: add device_attr_show script") CC: Denis Efremov Signed-off-by: kernel test robot --- tree: https://git.kernel.org/pub/scm/linux/kernel/git/jlawall/linux.git for-5.9 head: 5502a4eb3af819792a6c43b418c401f613a39d02 commit: 988676da837516bbfafda5478472fd4265f0de4e [1/3] coccinelle: api: add device_attr_show script :::::: branch date: 8 days ago :::::: commit date: 9 days ago Please take the patch only if it's a positive warning. Thanks! core.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -2668,7 +2668,7 @@ static ssize_t nvme_subsys_show_nqn(stru struct nvme_subsystem *subsys = container_of(dev, struct nvme_subsystem, dev); - return snprintf(buf, PAGE_SIZE, "%s\n", subsys->subnqn); + return scnprintf(buf, PAGE_SIZE, "%s\n", subsys->subnqn); } static SUBSYS_ATTR_RO(subsysnqn, S_IRUGO, nvme_subsys_show_nqn); @@ -3332,7 +3332,7 @@ static ssize_t nvme_sysfs_show_transport { struct nvme_ctrl *ctrl = dev_get_drvdata(dev); - return snprintf(buf, PAGE_SIZE, "%s\n", ctrl->ops->name); + return scnprintf(buf, PAGE_SIZE, "%s\n", ctrl->ops->name); } static DEVICE_ATTR(transport, S_IRUGO, nvme_sysfs_show_transport, NULL); @@ -3365,7 +3365,7 @@ static ssize_t nvme_sysfs_show_subsysnqn { struct nvme_ctrl *ctrl = dev_get_drvdata(dev); - return snprintf(buf, PAGE_SIZE, "%s\n", ctrl->subsys->subnqn); + return scnprintf(buf, PAGE_SIZE, "%s\n", ctrl->subsys->subnqn); } static DEVICE_ATTR(subsysnqn, S_IRUGO, nvme_sysfs_show_subsysnqn, NULL); @@ -3375,7 +3375,7 @@ static ssize_t nvme_sysfs_show_hostnqn(s { struct nvme_ctrl *ctrl = dev_get_drvdata(dev); - return snprintf(buf, PAGE_SIZE, "%s\n", ctrl->opts->host->nqn); + return scnprintf(buf, PAGE_SIZE, "%s\n", ctrl->opts->host->nqn); } static DEVICE_ATTR(hostnqn, S_IRUGO, nvme_sysfs_show_hostnqn, NULL); @@ -3385,7 +3385,7 @@ static ssize_t nvme_sysfs_show_hostid(st { struct nvme_ctrl *ctrl = dev_get_drvdata(dev); - return snprintf(buf, PAGE_SIZE, "%pU\n", &ctrl->opts->host->id); + return scnprintf(buf, PAGE_SIZE, "%pU\n", &ctrl->opts->host->id); } static DEVICE_ATTR(hostid, S_IRUGO, nvme_sysfs_show_hostid, NULL);