Re: [PATCH] zorro: sysfs: replace sprintf with sysfs_emit

From: Geert Uytterhoeven

Date: Mon Apr 27 2026 - 07:52:25 EST


Hi Stefan,

On Mon, 6 Apr 2026 at 19:26, Stefan Pedratscher
<pedratscher.stefan@xxxxxxxxx> wrote:
> 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@xxxxxxxxx>

Thanks for your patch!

> --- a/drivers/zorro/zorro-sysfs.c
> +++ b/drivers/zorro/zorro-sysfs.c
> @@ -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));

Wrong indentation.

> }
> static DEVICE_ATTR_RO(resource);
>

The rest LGTM, so
Reviewed-by: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>
i.e. will queue in the m68k tree for v7.2, with the above fixed.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds