From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============5175353623037086967==" MIME-Version: 1.0 From: kernel test robot Subject: [PATCH] coccinelle: api: fix device_attr_show.cocci warnings Date: Mon, 28 Dec 2020 04:05:00 +0800 Message-ID: <20201227200500.GA42830@8887daa46785> In-Reply-To: <202012280427.S5ZgodfV-lkp@intel.com> List-Id: To: kbuild@lists.01.org --===============5175353623037086967== 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: Richard Cochran CC: netdev(a)vger.kernel.org CC: linux-kernel(a)vger.kernel.org From: kernel test robot drivers/ptp/ptp_sysfs.c:16:8-16: WARNING: use scnprintf or sprintf drivers/ptp/ptp_sysfs.c:230: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: 52cd5f9c22eeef26d05f9d9338ba4eb38f14dd3a commit: abfc19ff202d287742483e15fd478ddd6ada2187 coccinelle: api: add devic= e_attr_show script :::::: branch date: 3 hours ago :::::: commit date: 5 months ago Please take the patch only if it's a positive warning. Thanks! ptp_sysfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/ptp/ptp_sysfs.c +++ b/drivers/ptp/ptp_sysfs.c @@ -13,7 +13,7 @@ static ssize_t clock_name_show(struct de struct device_attribute *attr, char *page) { struct ptp_clock *ptp =3D dev_get_drvdata(dev); - return snprintf(page, PAGE_SIZE-1, "%s\n", ptp->info->name); + return scnprintf(page, PAGE_SIZE-1, "%s\n", ptp->info->name); } static DEVICE_ATTR_RO(clock_name); = @@ -227,7 +227,7 @@ static ssize_t ptp_pin_show(struct devic = mutex_unlock(&ptp->pincfg_mux); = - return snprintf(page, PAGE_SIZE, "%u %u\n", func, chan); + return scnprintf(page, PAGE_SIZE, "%u %u\n", func, chan); } = static ssize_t ptp_pin_store(struct device *dev, struct device_attribute *= attr, --===============5175353623037086967==--