CC: kbuild-all(a)lists.01.org CC: linux-kernel(a)vger.kernel.org TO: Denis Efremov CC: Julia Lawall CC: Jens Axboe CC: linux-ide(a)vger.kernel.org CC: linux-kernel(a)vger.kernel.org From: kernel test robot drivers/ata/libata-sata.c:954:8-16: WARNING: use scnprintf or sprintf drivers/ata/libata-sata.c:830: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 Reported-by: kernel test robot Signed-off-by: kernel test robot --- tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: 2c85ebc57b3e1817b6ce1a6b703928e113a90442 commit: abfc19ff202d287742483e15fd478ddd6ada2187 coccinelle: api: add device_attr_show script :::::: branch date: 16 hours ago :::::: commit date: 4 months ago Please take the patch only if it's a positive warning. Thanks! libata-sata.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/ata/libata-sata.c +++ b/drivers/ata/libata-sata.c @@ -827,7 +827,7 @@ static ssize_t ata_scsi_lpm_show(struct if (ap->target_lpm_policy >= ARRAY_SIZE(ata_lpm_policy_names)) return -EINVAL; - return snprintf(buf, PAGE_SIZE, "%s\n", + return scnprintf(buf, PAGE_SIZE, "%s\n", ata_lpm_policy_names[ap->target_lpm_policy]); } DEVICE_ATTR(link_power_management_policy, S_IRUGO | S_IWUSR, @@ -951,7 +951,7 @@ ata_scsi_em_message_type_show(struct dev struct Scsi_Host *shost = class_to_shost(dev); struct ata_port *ap = ata_shost_to_port(shost); - return snprintf(buf, 23, "%d\n", ap->em_message_type); + return scnprintf(buf, 23, "%d\n", ap->em_message_type); } DEVICE_ATTR(em_message_type, S_IRUGO, ata_scsi_em_message_type_show, NULL);