* [PATCH] coccinelle: api: fix device_attr_show.cocci warnings
[not found] <202008130840.TWLDLwLA%lkp@intel.com>
@ 2020-08-13 0:56 ` kernel test robot
0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2020-08-13 0:56 UTC (permalink / raw)
To: Denis Efremov
Cc: kbuild-all, linux-kernel, Julia Lawall, Rafael J. Wysocki,
Len Brown, linux-acpi
From: kernel test robot <lkp@intel.com>
drivers/acpi/dock.c:563:8-16: WARNING: use scnprintf or sprintf
drivers/acpi/dock.c:544:8-16: WARNING: use scnprintf or sprintf
drivers/acpi/dock.c:495:8-16: WARNING: use scnprintf or sprintf
drivers/acpi/dock.c:506: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 <efremov@linux.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: 7c2a69f610e64c8dec6a06a66e721f4ce1dd783a
commit: abfc19ff202d287742483e15fd478ddd6ada2187 coccinelle: api: add device_attr_show script
Please take the patch only if it's a positive warning. Thanks!
dock.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
--- a/drivers/acpi/dock.c
+++ b/drivers/acpi/dock.c
@@ -492,7 +492,7 @@ static ssize_t show_docked(struct device
struct acpi_device *adev = NULL;
acpi_bus_get_device(dock_station->handle, &adev);
- return snprintf(buf, PAGE_SIZE, "%u\n", acpi_device_enumerated(adev));
+ return scnprintf(buf, PAGE_SIZE, "%u\n", acpi_device_enumerated(adev));
}
static DEVICE_ATTR(docked, S_IRUGO, show_docked, NULL);
@@ -503,7 +503,7 @@ static ssize_t show_flags(struct device
struct device_attribute *attr, char *buf)
{
struct dock_station *dock_station = dev->platform_data;
- return snprintf(buf, PAGE_SIZE, "%d\n", dock_station->flags);
+ return scnprintf(buf, PAGE_SIZE, "%d\n", dock_station->flags);
}
static DEVICE_ATTR(flags, S_IRUGO, show_flags, NULL);
@@ -541,7 +541,7 @@ static ssize_t show_dock_uid(struct devi
if (ACPI_FAILURE(status))
return 0;
- return snprintf(buf, PAGE_SIZE, "%llx\n", lbuf);
+ return scnprintf(buf, PAGE_SIZE, "%llx\n", lbuf);
}
static DEVICE_ATTR(uid, S_IRUGO, show_dock_uid, NULL);
@@ -560,7 +560,7 @@ static ssize_t show_dock_type(struct dev
else
type = "unknown";
- return snprintf(buf, PAGE_SIZE, "%s\n", type);
+ return scnprintf(buf, PAGE_SIZE, "%s\n", type);
}
static DEVICE_ATTR(type, S_IRUGO, show_dock_type, NULL);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-08-13 0:57 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <202008130840.TWLDLwLA%lkp@intel.com>
2020-08-13 0:56 ` [PATCH] coccinelle: api: fix device_attr_show.cocci warnings kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).