* [PATCH] coccinelle: api: fix device_attr_show.cocci warnings
2020-11-17 17:21 drivers/net/can/at91_can.c:1185:9-17: WARNING: use scnprintf or sprintf kernel test robot
@ 2020-11-17 17:21 ` kernel test robot
0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2020-11-17 17:21 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 2154 bytes --]
CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Denis Efremov <efremov@linux.com>
CC: Julia Lawall <Julia.Lawall@lip6.fr>
CC: Wolfgang Grandegger <wg@grandegger.com>
CC: "Marc Kleine-Budde" <mkl@pengutronix.de>
CC: Jakub Kicinski <kuba@kernel.org>
CC: Nicolas Ferre <nicolas.ferre@microchip.com>
CC: Alexandre Belloni <alexandre.belloni@bootlin.com>
CC: Ludovic Desroches <ludovic.desroches@microchip.com>
CC: linux-can(a)vger.kernel.org
CC: netdev(a)vger.kernel.org
From: kernel test robot <lkp@intel.com>
drivers/net/can/at91_can.c:1185:9-17: 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 <efremov@linux.com>
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: kernel test robot <lkp@intel.com>
---
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 9c87c9f41245baa3fc4716cf39141439cf405b01
commit: abfc19ff202d287742483e15fd478ddd6ada2187 coccinelle: api: add device_attr_show script
:::::: branch date: 18 hours ago
:::::: commit date: 4 months ago
Please take the patch only if it's a positive warning. Thanks!
at91_can.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--- a/drivers/net/can/at91_can.c
+++ b/drivers/net/can/at91_can.c
@@ -1182,9 +1182,9 @@ static ssize_t at91_sysfs_show_mb0_id(st
struct at91_priv *priv = netdev_priv(to_net_dev(dev));
if (priv->mb0_id & CAN_EFF_FLAG)
- return snprintf(buf, PAGE_SIZE, "0x%08x\n", priv->mb0_id);
+ return scnprintf(buf, PAGE_SIZE, "0x%08x\n", priv->mb0_id);
else
- return snprintf(buf, PAGE_SIZE, "0x%03x\n", priv->mb0_id);
+ return scnprintf(buf, PAGE_SIZE, "0x%03x\n", priv->mb0_id);
}
static ssize_t at91_sysfs_set_mb0_id(struct device *dev,
^ permalink raw reply [flat|nested] 2+ messages in thread