From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============0043396350566485360==" MIME-Version: 1.0 From: kernel test robot Subject: [PATCH] coccinelle: api: fix device_attr_show.cocci warnings Date: Fri, 11 Dec 2020 05:20:15 +0800 Message-ID: <20201210212015.GA27246@1282cbe5153c> In-Reply-To: <202012110503.s0x37MC7-lkp@intel.com> List-Id: To: kbuild@lists.01.org --===============0043396350566485360== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable CC: kbuild-all(a)lists.01.org CC: linux-kernel(a)vger.kernel.org TO: Denis Efremov CC: Julia Lawall 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/wacom_sys.c:1796: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: 9fca90cf28920c6d0723d7efd1eae0b0fb90309c commit: abfc19ff202d287742483e15fd478ddd6ada2187 coccinelle: api: add devic= e_attr_show script :::::: branch date: 2 hours ago :::::: commit date: 4 months ago Please take the patch only if it's a positive warning. Thanks! wacom_sys.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/hid/wacom_sys.c +++ b/drivers/hid/wacom_sys.c @@ -1793,7 +1793,7 @@ static ssize_t wacom_show_speed(struct d struct hid_device *hdev =3D to_hid_device(dev); struct wacom *wacom =3D hid_get_drvdata(hdev); = - return snprintf(buf, PAGE_SIZE, "%i\n", wacom->wacom_wac.bt_high_speed); + return scnprintf(buf, PAGE_SIZE, "%i\n", wacom->wacom_wac.bt_high_speed); } = static ssize_t wacom_store_speed(struct device *dev, --===============0043396350566485360==--