From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============6153958579332091274==" MIME-Version: 1.0 From: kernel test robot Subject: [PATCH] coccinelle: api: fix device_attr_show.cocci warnings Date: Wed, 02 Sep 2020 20:37:24 +0800 Message-ID: <20200902123723.GA83010@b6768a2e92b6> In-Reply-To: <202009022030.kO26QkOc%lkp@intel.com> List-Id: To: kbuild@lists.01.org --===============6153958579332091274== 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: Borislav Petkov CC: Mauro Carvalho Chehab CC: linux-media(a)vger.kernel.org CC: Tony Luck CC: James Morse CC: Robert Richter CC: linux-edac(a)vger.kernel.org CC: linux-kernel(a)vger.kernel.org From: kernel test robot drivers/edac/edac_mc_sysfs.c:210:8-16: WARNING: use scnprintf or sprintf drivers/edac/edac_mc_sysfs.c:490: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: 9c7d619be5a002ea29c172df5e3c1227c22cbb41 commit: abfc19ff202d287742483e15fd478ddd6ada2187 coccinelle: api: add devic= e_attr_show script :::::: branch date: 10 hours ago :::::: commit date: 4 weeks ago Please take the patch only if it's a positive warning. Thanks! edac_mc_sysfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/edac/edac_mc_sysfs.c +++ b/drivers/edac/edac_mc_sysfs.c @@ -207,7 +207,7 @@ static ssize_t channel_dimm_label_show(s if (!rank->dimm->label[0]) return 0; = - return snprintf(data, sizeof(rank->dimm->label) + 1, "%s\n", + return scnprintf(data, sizeof(rank->dimm->label) + 1, "%s\n", rank->dimm->label); } = @@ -487,7 +487,7 @@ static ssize_t dimmdev_label_show(struct if (!dimm->label[0]) return 0; = - return snprintf(data, sizeof(dimm->label) + 1, "%s\n", dimm->label); + return scnprintf(data, sizeof(dimm->label) + 1, "%s\n", dimm->label); } = static ssize_t dimmdev_label_store(struct device *dev, --===============6153958579332091274==--