Skip to contentSkip to conversation

drivers/perf/fsl_imx8_ddr_perf.c:119:8-16: WARNING: use scnprintf or sprintf

DISCUSSION kernel test robot 1 participant 2 messages Nov 30, 2020

Subsystems (3)
lore
Share & tools
lore

kernel test robot

author build bot
#0 lore raw

CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Denis Efremov <[email protected]>
CC: Julia Lawall <[email protected]>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   b65054597872ce3aefbc6a666385eabdf9e288da
commit: abfc19ff202d287742483e15fd478ddd6ada2187 coccinelle: api: add device_attr_show script
date:   4 months ago

:::::: branch date: 22 hours ago
:::::: commit date: 4 months ago
config: arm-randconfig-c003-20201130 (attached as .config)
compiler: arm-linux-gnueabi-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate

"coccinelle warnings: (new ones prefixed by >>)"

>> drivers/perf/fsl_imx8_ddr_perf.c:119:8-16: WARNING: use scnprintf or sprintf

Please review and possibly fold the followup patch.

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

author build bot
#1 lore raw

[PATCH] coccinelle: api: fix device_attr_show.cocci warnings

CC: kbuild-all(a)lists.01.org CC: linux-kernel(a)vger.kernel.org TO: Denis Efremov <[email protected]> CC: Julia Lawall <[email protected]> CC: Frank Li <[email protected]> CC: Will Deacon…

CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Denis Efremov <[email protected]>
CC: Julia Lawall <[email protected]>
CC: Frank Li <[email protected]>
CC: Will Deacon <[email protected]>
CC: Mark Rutland <[email protected]>
CC: Shawn Guo <[email protected]>
CC: Sascha Hauer <[email protected]>
CC: Pengutronix Kernel Team <[email protected]>
CC: Fabio Estevam <[email protected]>
CC: NXP Linux Team <[email protected]>

From: kernel test robot <[email protected]>

drivers/perf/fsl_imx8_ddr_perf.c:119: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 <[email protected]>

---

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   b65054597872ce3aefbc6a666385eabdf9e288da
commit: abfc19ff202d287742483e15fd478ddd6ada2187 coccinelle: api: add device_attr_show script

:::::: branch date: 22 hours ago
:::::: commit date: 4 months ago

Please take the patch only if it's a positive warning. Thanks!

 fsl_imx8_ddr_perf.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/perf/fsl_imx8_ddr_perf.c +1 -1
@@ -116,7 +116,7 @@ static ssize_t ddr_perf_filter_cap_show(
 		container_of(attr, struct dev_ext_attribute, attr);
 	int cap = (long)ea->var;
 
-	return snprintf(buf, PAGE_SIZE, "%u\n",
+	return scnprintf(buf, PAGE_SIZE, "%u\n",
 			ddr_perf_filter_cap_get(pmu, cap));
 }