From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============6949256654409797976==" MIME-Version: 1.0 From: kernel test robot Subject: [PATCH] coccinelle: api: fix device_attr_show.cocci warnings Date: Tue, 15 Sep 2020 15:28:29 +0800 Message-ID: <20200915072829.GA61631@18a20b5b1e11> In-Reply-To: <202009151518.5Lnrqizo%lkp@intel.com> List-Id: To: kbuild@lists.01.org --===============6949256654409797976== 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: Valentina Manea CC: Shuah Khan CC: "Greg Kroah-Hartman" CC: linux-usb(a)vger.kernel.org CC: linux-kernel(a)vger.kernel.org From: kernel test robot drivers/usb/usbip/vudc_sysfs.c:203: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: fc4f28bb3daf3265d6bc5f73b497306985bb23ab commit: abfc19ff202d287742483e15fd478ddd6ada2187 coccinelle: api: add devic= e_attr_show script :::::: branch date: 9 hours ago :::::: commit date: 6 weeks ago Please take the patch only if it's a positive warning. Thanks! vudc_sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/usb/usbip/vudc_sysfs.c +++ b/drivers/usb/usbip/vudc_sysfs.c @@ -200,7 +200,7 @@ static ssize_t usbip_status_show(struct status =3D udc->ud.status; spin_unlock_irq(&udc->ud.lock); = - return snprintf(out, PAGE_SIZE, "%d\n", status); + return scnprintf(out, PAGE_SIZE, "%d\n", status); } static DEVICE_ATTR_RO(usbip_status); =20 --===============6949256654409797976==--