From: kernel test robot drivers/hid/hid-roccat-kone.c:406:8-16: WARNING: use scnprintf or sprintf drivers/hid/hid-roccat-kone.c:397:8-16: WARNING: use scnprintf or sprintf drivers/hid/hid-roccat-kone.c:438:8-16: WARNING: use scnprintf or sprintf drivers/hid/hid-roccat-kone.c:550:8-16: WARNING: use scnprintf or sprintf drivers/hid/hid-roccat-kone.c:448:8-16: WARNING: use scnprintf or sprintf drivers/hid/hid-roccat-kone.c:429: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: 7c2a69f610e64c8dec6a06a66e721f4ce1dd783a commit: abfc19ff202d287742483e15fd478ddd6ada2187 coccinelle: api: add device_attr_show script Please take the patch only if it's a positive warning. Thanks! hid-roccat-kone.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) --- a/drivers/hid/hid-roccat-kone.c +++ b/drivers/hid/hid-roccat-kone.c @@ -394,7 +394,7 @@ static ssize_t kone_sysfs_show_actual_pr { struct kone_device *kone = hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); - return snprintf(buf, PAGE_SIZE, "%d\n", kone->actual_profile); + return scnprintf(buf, PAGE_SIZE, "%d\n", kone->actual_profile); } static DEVICE_ATTR(actual_profile, 0440, kone_sysfs_show_actual_profile, NULL); @@ -403,7 +403,7 @@ static ssize_t kone_sysfs_show_actual_dp { struct kone_device *kone = hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); - return snprintf(buf, PAGE_SIZE, "%d\n", kone->actual_dpi); + return scnprintf(buf, PAGE_SIZE, "%d\n", kone->actual_dpi); } static DEVICE_ATTR(actual_dpi, 0440, kone_sysfs_show_actual_dpi, NULL); @@ -426,7 +426,7 @@ static ssize_t kone_sysfs_show_weight(st if (retval) return retval; - return snprintf(buf, PAGE_SIZE, "%d\n", weight); + return scnprintf(buf, PAGE_SIZE, "%d\n", weight); } static DEVICE_ATTR(weight, 0440, kone_sysfs_show_weight, NULL); @@ -435,7 +435,7 @@ static ssize_t kone_sysfs_show_firmware_ { struct kone_device *kone = hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); - return snprintf(buf, PAGE_SIZE, "%d\n", kone->firmware_version); + return scnprintf(buf, PAGE_SIZE, "%d\n", kone->firmware_version); } static DEVICE_ATTR(firmware_version, 0440, kone_sysfs_show_firmware_version, NULL); @@ -445,7 +445,7 @@ static ssize_t kone_sysfs_show_tcu(struc { struct kone_device *kone = hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); - return snprintf(buf, PAGE_SIZE, "%d\n", kone->settings.tcu); + return scnprintf(buf, PAGE_SIZE, "%d\n", kone->settings.tcu); } static int kone_tcu_command(struct usb_device *usb_dev, int number) @@ -547,7 +547,7 @@ static ssize_t kone_sysfs_show_startup_p { struct kone_device *kone = hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); - return snprintf(buf, PAGE_SIZE, "%d\n", kone->settings.startup_profile); + return scnprintf(buf, PAGE_SIZE, "%d\n", kone->settings.startup_profile); } static ssize_t kone_sysfs_set_startup_profile(struct device *dev,