From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============0820241414122333520==" MIME-Version: 1.0 From: kernel test robot Subject: [PATCH] coccinelle: api: fix device_attr_show.cocci warnings Date: Sun, 13 Sep 2020 06:57:09 +0800 Message-ID: <20200912225709.GA78711@65b6a7d1c60d> In-Reply-To: <202009130646.B9ZzJMqB%lkp@intel.com> List-Id: To: kbuild@lists.01.org --===============0820241414122333520== 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: Intel SCU Linux support CC: Artur Paszkiewicz CC: "James E.J. Bottomley" CC: "Martin K. Petersen" CC: linux-scsi(a)vger.kernel.org CC: linux-kernel(a)vger.kernel.org From: kernel test robot drivers/scsi/isci/init.c:140: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: 729e3d091984487f7aa1ebfabfe594e5b317ed0f commit: abfc19ff202d287742483e15fd478ddd6ada2187 coccinelle: api: add devic= e_attr_show script :::::: branch date: 26 hours ago :::::: commit date: 6 weeks ago Please take the patch only if it's a positive warning. Thanks! init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/scsi/isci/init.c +++ b/drivers/scsi/isci/init.c @@ -137,7 +137,7 @@ static ssize_t isci_show_id(struct devic struct sas_ha_struct *sas_ha =3D SHOST_TO_SAS_HA(shost); struct isci_host *ihost =3D container_of(sas_ha, typeof(*ihost), sas_ha); = - return snprintf(buf, PAGE_SIZE, "%d\n", ihost->id); + return scnprintf(buf, PAGE_SIZE, "%d\n", ihost->id); } = static DEVICE_ATTR(isci_id, S_IRUGO, isci_show_id, NULL); --===============0820241414122333520==--