summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Pedratscher <pedratscher.stefan@gmail.com>2026-04-06 20:25:12 +0300
committerGeert Uytterhoeven <geert@linux-m68k.org>2026-04-27 14:52:12 +0300
commit99a680bed60428175ff9c5c95d579826ca2ff3f8 (patch)
tree91c97bc8b592f8088e9597f3bd4b5119ccfb6b5c
parent254f49634ee16a731174d2ae34bc50bd5f45e731 (diff)
downloadlinux-99a680bed60428175ff9c5c95d579826ca2ff3f8.tar.xz
zorro: sysfs: Replace sprintf() by sysfs_emit()
Convert sysfs show functions from sprintf() to sysfs_emit(), as recommended by Documentation/filesystems/sysfs.rst. This ensures proper buffer handling and avoids potential buffer overflows. Signed-off-by: Stefan Pedratscher <pedratscher.stefan@gmail.com> Tested-by: Daniel Palmer <daniel@thingy.jp> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org> Link: https://patch.msgid.link/20260406172512.6693-1-pedratscher.stefan@gmail.com Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
-rw-r--r--drivers/zorro/zorro-sysfs.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/drivers/zorro/zorro-sysfs.c b/drivers/zorro/zorro-sysfs.c
index 4e967754d8ad..9989240fb76b 100644
--- a/drivers/zorro/zorro-sysfs.c
+++ b/drivers/zorro/zorro-sysfs.c
@@ -15,6 +15,7 @@
#include <linux/zorro.h>
#include <linux/stat.h>
#include <linux/string.h>
+#include <linux/sysfs.h>
#include <asm/byteorder.h>
@@ -29,7 +30,7 @@ static ssize_t name##_show(struct device *dev, \
struct zorro_dev *z; \
\
z = to_zorro_dev(dev); \
- return sprintf(buf, format_string, z->field); \
+ return sysfs_emit(buf, format_string, z->field); \
} \
static DEVICE_ATTR_RO(name);
@@ -44,7 +45,7 @@ static ssize_t serial_show(struct device *dev, struct device_attribute *attr,
struct zorro_dev *z;
z = to_zorro_dev(dev);
- return sprintf(buf, "0x%08x\n", be32_to_cpu(z->rom.er_SerialNumber));
+ return sysfs_emit(buf, "0x%08x\n", be32_to_cpu(z->rom.er_SerialNumber));
}
static DEVICE_ATTR_RO(serial);
@@ -53,10 +54,10 @@ static ssize_t resource_show(struct device *dev, struct device_attribute *attr,
{
struct zorro_dev *z = to_zorro_dev(dev);
- return sprintf(buf, "0x%08lx 0x%08lx 0x%08lx\n",
- (unsigned long)zorro_resource_start(z),
- (unsigned long)zorro_resource_end(z),
- zorro_resource_flags(z));
+ return sysfs_emit(buf, "0x%08lx 0x%08lx 0x%08lx\n",
+ (unsigned long)zorro_resource_start(z),
+ (unsigned long)zorro_resource_end(z),
+ zorro_resource_flags(z));
}
static DEVICE_ATTR_RO(resource);
@@ -65,7 +66,7 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
{
struct zorro_dev *z = to_zorro_dev(dev);
- return sprintf(buf, ZORRO_DEVICE_MODALIAS_FMT "\n", z->id);
+ return sysfs_emit(buf, ZORRO_DEVICE_MODALIAS_FMT "\n", z->id);
}
static DEVICE_ATTR_RO(modalias);