From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============5931549983237963594==" MIME-Version: 1.0 From: kernel test robot Subject: [PATCH] coccinelle: api: fix device_attr_show.cocci warnings Date: Mon, 07 Dec 2020 14:03:41 +0800 Message-ID: <20201207060341.GA35265@0ee60fe6aa9f> In-Reply-To: <202012071400.813Eb0bI-lkp@intel.com> List-Id: To: kbuild@lists.01.org --===============5931549983237963594== 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: Wolfgang Grandegger CC: "Marc Kleine-Budde" CC: Jakub Kicinski CC: linux-can(a)vger.kernel.org CC: netdev(a)vger.kernel.org CC: linux-kernel(a)vger.kernel.org From: kernel test robot drivers/net/can/janz-ican3.c:1834: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: 0477e92881850d44910a7e94fc2c46f96faa131f commit: abfc19ff202d287742483e15fd478ddd6ada2187 coccinelle: api: add devic= e_attr_show script :::::: branch date: 8 hours ago :::::: commit date: 4 months ago Please take the patch only if it's a positive warning. Thanks! janz-ican3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/net/can/janz-ican3.c +++ b/drivers/net/can/janz-ican3.c @@ -1831,7 +1831,7 @@ static ssize_t ican3_sysfs_show_term(str return -ETIMEDOUT; } = - return snprintf(buf, PAGE_SIZE, "%u\n", mod->termination_enabled); + return scnprintf(buf, PAGE_SIZE, "%u\n", mod->termination_enabled); } = static ssize_t ican3_sysfs_set_term(struct device *dev, --===============5931549983237963594==--