* [PATCH] drivers: dio: replace deprecated strcpy with strscpy in dio_init
@ 2026-04-30 12:05 Thorsten Blum
2026-05-04 7:17 ` Geert Uytterhoeven
0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Blum @ 2026-04-30 12:05 UTC (permalink / raw)
To: Kees Cook; +Cc: linux-kernel, linux-m68k, Thorsten Blum
strcpy() has been deprecated [1] because it performs no bounds checking
on the destination buffer, which can lead to buffer overflows. While the
current code works correctly, replace strcpy() with the safer strscpy()
to follow secure coding best practices.
Indent multiple lines using tabs instead of spaces, and use pr_info()
and avoid continuation logging while at it.
[1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
drivers/dio/dio.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/drivers/dio/dio.c b/drivers/dio/dio.c
index 419b3c13d491..b39ae25d060e 100644
--- a/drivers/dio/dio.c
+++ b/drivers/dio/dio.c
@@ -178,7 +178,7 @@ static int __init dio_init(void)
if (!MACH_IS_HP300)
return 0;
- printk(KERN_INFO "Scanning for DIO devices...\n");
+ pr_info("Scanning for DIO devices...\n");
/* Initialize the DIO bus */
INIT_LIST_HEAD(&dio_bus.devices);
@@ -247,18 +247,19 @@ static int __init dio_init(void)
dev->id = prid;
dev->ipl = DIO_IPL(va);
- strcpy(dev->name, dio_getname(dev->id));
- printk(KERN_INFO "select code %3d: ipl %d: ID %02X", dev->scode, dev->ipl, prid);
+ strscpy(dev->name, dio_getname(dev->id));
if (DIO_NEEDSSECID(prid))
- printk(":%02X", secid);
- printk(": %s\n", dev->name);
+ pr_info("select code %3d: ipl %d: ID %02X:%02X: %s\n",
+ dev->scode, dev->ipl, prid, secid, dev->name);
+ else
+ pr_info("select code %3d: ipl %d: ID %02X: %s\n",
+ dev->scode, dev->ipl, prid, dev->name);
if (scode >= DIOII_SCBASE)
iounmap(va);
error = device_register(&dev->dev);
if (error) {
- pr_err("DIO: Error registering device %s\n",
- dev->name);
+ pr_err("DIO: Error registering device %s\n", dev->name);
put_device(&dev->dev);
continue;
}
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] drivers: dio: replace deprecated strcpy with strscpy in dio_init
2026-04-30 12:05 [PATCH] drivers: dio: replace deprecated strcpy with strscpy in dio_init Thorsten Blum
@ 2026-05-04 7:17 ` Geert Uytterhoeven
0 siblings, 0 replies; 2+ messages in thread
From: Geert Uytterhoeven @ 2026-05-04 7:17 UTC (permalink / raw)
To: Thorsten Blum; +Cc: Kees Cook, linux-kernel, linux-m68k
Hi Thorsten,
On Thu, 30 Apr 2026 at 14:09, Thorsten Blum <thorsten.blum@linux.dev> wrote:
> strcpy() has been deprecated [1] because it performs no bounds checking
> on the destination buffer, which can lead to buffer overflows. While the
> current code works correctly, replace strcpy() with the safer strscpy()
> to follow secure coding best practices.
>
> Indent multiple lines using tabs instead of spaces, and use pr_info()
> and avoid continuation logging while at it.
>
> [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy
>
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Thanks for your patch!
Please split this in two patches, as the "while at it" became much
larger than the main change.
> --- a/drivers/dio/dio.c
> +++ b/drivers/dio/dio.c
> @@ -178,7 +178,7 @@ static int __init dio_init(void)
> if (!MACH_IS_HP300)
> return 0;
>
> - printk(KERN_INFO "Scanning for DIO devices...\n");
> + pr_info("Scanning for DIO devices...\n");
>
> /* Initialize the DIO bus */
> INIT_LIST_HEAD(&dio_bus.devices);
> @@ -247,18 +247,19 @@ static int __init dio_init(void)
> dev->id = prid;
>
> dev->ipl = DIO_IPL(va);
> - strcpy(dev->name, dio_getname(dev->id));
> - printk(KERN_INFO "select code %3d: ipl %d: ID %02X", dev->scode, dev->ipl, prid);
> + strscpy(dev->name, dio_getname(dev->id));
> if (DIO_NEEDSSECID(prid))
> - printk(":%02X", secid);
> - printk(": %s\n", dev->name);
> + pr_info("select code %3d: ipl %d: ID %02X:%02X: %s\n",
> + dev->scode, dev->ipl, prid, secid, dev->name);
> + else
> + pr_info("select code %3d: ipl %d: ID %02X: %s\n",
> + dev->scode, dev->ipl, prid, dev->name);
Looks like a good opportunity to start using "%u" to print dev->ipl,
which is u8.
>
> if (scode >= DIOII_SCBASE)
> iounmap(va);
The rest LGTM to me.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-05-04 7:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-30 12:05 [PATCH] drivers: dio: replace deprecated strcpy with strscpy in dio_init Thorsten Blum
2026-05-04 7:17 ` Geert Uytterhoeven
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox