CC: kbuild-all(a)lists.01.org CC: linux-kernel(a)vger.kernel.org TO: Denis Efremov CC: Julia Lawall CC: "Bruno Prémont" CC: Jiri Kosina CC: Benjamin Tissoires CC: linux-input(a)vger.kernel.org CC: linux-kernel(a)vger.kernel.org From: kernel test robot drivers/hid/hid-picolcd_core.c:304:8-16: WARNING: use scnprintf or sprintf drivers/hid/hid-picolcd_core.c:259:9-17: 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: 52cd5f9c22eeef26d05f9d9338ba4eb38f14dd3a commit: abfc19ff202d287742483e15fd478ddd6ada2187 coccinelle: api: add device_attr_show script :::::: branch date: 3 hours ago :::::: commit date: 5 months ago Please take the patch only if it's a positive warning. Thanks! hid-picolcd_core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/drivers/hid/hid-picolcd_core.c +++ b/drivers/hid/hid-picolcd_core.c @@ -256,9 +256,9 @@ static ssize_t picolcd_operation_mode_sh struct picolcd_data *data = dev_get_drvdata(dev); if (data->status & PICOLCD_BOOTLOADER) - return snprintf(buf, PAGE_SIZE, "[bootloader] lcd\n"); + return scnprintf(buf, PAGE_SIZE, "[bootloader] lcd\n"); else - return snprintf(buf, PAGE_SIZE, "bootloader [lcd]\n"); + return scnprintf(buf, PAGE_SIZE, "bootloader [lcd]\n"); } static ssize_t picolcd_operation_mode_store(struct device *dev, @@ -301,7 +301,7 @@ static ssize_t picolcd_operation_mode_de { struct picolcd_data *data = dev_get_drvdata(dev); - return snprintf(buf, PAGE_SIZE, "%hu\n", data->opmode_delay); + return scnprintf(buf, PAGE_SIZE, "%hu\n", data->opmode_delay); } static ssize_t picolcd_operation_mode_delay_store(struct device *dev,