CC: kbuild-all(a)lists.01.org CC: linux-kernel(a)vger.kernel.org TO: Denis Efremov CC: Julia Lawall CC: Justin Sanders CC: Jens Axboe CC: linux-block(a)vger.kernel.org CC: linux-kernel(a)vger.kernel.org From: kernel test robot drivers/block/aoe/aoeblk.c:102:8-16: WARNING: use scnprintf or sprintf drivers/block/aoe/aoeblk.c:55:9-17: WARNING: use scnprintf or sprintf drivers/block/aoe/aoeblk.c:88:9-17: WARNING: use scnprintf or sprintf drivers/block/aoe/aoeblk.c:110:8-16: WARNING: use scnprintf or sprintf drivers/block/aoe/aoeblk.c:40: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: abfc19ff202d ("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/torvalds/linux.git master head: 60e720931556fc1034d0981460164dcf02697679 commit: abfc19ff202d287742483e15fd478ddd6ada2187 coccinelle: api: add device_attr_show script :::::: branch date: 7 hours ago :::::: commit date: 8 weeks ago Please take the patch only if it's a positive warning. Thanks! aoeblk.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) --- a/drivers/block/aoe/aoeblk.c +++ b/drivers/block/aoe/aoeblk.c @@ -37,7 +37,7 @@ static ssize_t aoedisk_show_state(struct struct gendisk *disk = dev_to_disk(dev); struct aoedev *d = disk->private_data; - return snprintf(page, PAGE_SIZE, + return scnprintf(page, PAGE_SIZE, "%s%s\n", (d->flags & DEVFL_UP) ? "up" : "down", (d->flags & DEVFL_KICKME) ? ",kickme" : @@ -52,8 +52,8 @@ static ssize_t aoedisk_show_mac(struct d struct aoetgt *t = d->targets[0]; if (t == NULL) - return snprintf(page, PAGE_SIZE, "none\n"); - return snprintf(page, PAGE_SIZE, "%pm\n", t->addr); + return scnprintf(page, PAGE_SIZE, "none\n"); + return scnprintf(page, PAGE_SIZE, "%pm\n", t->addr); } static ssize_t aoedisk_show_netif(struct device *dev, struct device_attribute *attr, char *page) @@ -85,7 +85,7 @@ static ssize_t aoedisk_show_netif(struct ne = nd; nd = nds; if (*nd == NULL) - return snprintf(page, PAGE_SIZE, "none\n"); + return scnprintf(page, PAGE_SIZE, "none\n"); for (p = page; nd < ne; nd++) p += scnprintf(p, PAGE_SIZE - (p-page), "%s%s", p == page ? "" : ",", (*nd)->name); @@ -99,7 +99,7 @@ static ssize_t aoedisk_show_fwver(struct struct gendisk *disk = dev_to_disk(dev); struct aoedev *d = disk->private_data; - return snprintf(page, PAGE_SIZE, "0x%04x\n", (unsigned int) d->fw_ver); + return scnprintf(page, PAGE_SIZE, "0x%04x\n", (unsigned int) d->fw_ver); } static ssize_t aoedisk_show_payload(struct device *dev, struct device_attribute *attr, char *page) @@ -107,7 +107,7 @@ static ssize_t aoedisk_show_payload(stru struct gendisk *disk = dev_to_disk(dev); struct aoedev *d = disk->private_data; - return snprintf(page, PAGE_SIZE, "%lu\n", d->maxbcnt); + return scnprintf(page, PAGE_SIZE, "%lu\n", d->maxbcnt); } static int aoedisk_debugfs_show(struct seq_file *s, void *ignored)