From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============7322968902379014426==" MIME-Version: 1.0 From: kernel test robot Subject: [PATCH] coccinelle: api: fix device_attr_show.cocci warnings Date: Fri, 03 Jul 2020 19:35:49 +0800 Message-ID: <20200703113549.GA18422@bf425ecdd42c> In-Reply-To: <202007031941.um9p1FRJ%lkp@intel.com> List-Id: To: kbuild@lists.01.org --===============7322968902379014426== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable CC: kbuild-all(a)lists.01.org TO: Denis Efremov CC: Julia Lawall CC: "Greg Kroah-Hartman" CC: Jiri Slaby CC: Andy Shevchenko CC: Lukas Wunner CC: Vignesh Raghavendra CC: Aaron Sierra CC: linux-serial(a)vger.kernel.org CC: linux-kernel(a)vger.kernel.org From: kernel test robot drivers/tty/serial/8250/8250_port.c:2989:8-16: WARNING: use scnprintf or sp= rintf 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: 988676da8375 ("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/jlawall/linux.git f= or-5.9 head: 5502a4eb3af819792a6c43b418c401f613a39d02 commit: 988676da837516bbfafda5478472fd4265f0de4e [1/3] coccinelle: api: add= device_attr_show script :::::: branch date: 8 days ago :::::: commit date: 9 days ago Please take the patch only if it's a positive warning. Thanks! 8250_port.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -2986,7 +2986,7 @@ static ssize_t rx_trig_bytes_show(struct if (rxtrig_bytes < 0) return rxtrig_bytes; = - return snprintf(buf, PAGE_SIZE, "%d\n", rxtrig_bytes); + return scnprintf(buf, PAGE_SIZE, "%d\n", rxtrig_bytes); } = static int do_set_rxtrig(struct tty_port *port, unsigned char bytes) --===============7322968902379014426==--