From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============6797264911872396470==" MIME-Version: 1.0 From: kernel test robot Subject: [PATCH] coccinelle: api: fix device_attr_show.cocci warnings Date: Wed, 09 Sep 2020 23:04:51 +0800 Message-ID: <20200909150451.GA9696@8edef15e043a> In-Reply-To: <202009092356.ZdQryKOu%lkp@intel.com> List-Id: To: kbuild@lists.01.org --===============6797264911872396470== 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: Peter Zijlstra CC: Ingo Molnar CC: Arnaldo Carvalho de Melo CC: Mark Rutland CC: Alexander Shishkin CC: Jiri Olsa CC: Namhyung Kim CC: Thomas Gleixner From: kernel test robot arch/x86/events/intel/pt.c:95: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: 34d4ddd359dbcdf6c5fb3f85a179243d7a1cb7f8 commit: abfc19ff202d287742483e15fd478ddd6ada2187 coccinelle: api: add devic= e_attr_show script :::::: branch date: 20 hours ago :::::: commit date: 5 weeks ago Please take the patch only if it's a positive warning. Thanks! pt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/x86/events/intel/pt.c +++ b/arch/x86/events/intel/pt.c @@ -92,7 +92,7 @@ static ssize_t pt_cap_show(struct device container_of(attr, struct dev_ext_attribute, attr); enum pt_capabilities cap =3D (long)ea->var; = - return snprintf(buf, PAGE_SIZE, "%x\n", intel_pt_validate_hw_cap(cap)); + return scnprintf(buf, PAGE_SIZE, "%x\n", intel_pt_validate_hw_cap(cap)); } = static struct attribute_group pt_cap_group __ro_after_init =3D { --===============6797264911872396470==--