mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] sonypi: use strscpy() in sonypi_acpi_probe
@ 2026-04-24  7:57 Thorsten Blum
  2026-04-24  8:34 ` Arnd Bergmann
  2026-04-28 16:05 ` Ilpo Järvinen
  0 siblings, 2 replies; 3+ messages in thread
From: Thorsten Blum @ 2026-04-24  7:57 UTC (permalink / raw)
  To: Mattia Dongili, Arnd Bergmann, Greg Kroah-Hartman
  Cc: Thorsten Blum, platform-driver-x86, linux-kernel

strcpy() has been deprecated¹ 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.

¹ https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
Based on linux-next and the new function name sonypi_acpi_probe().
---
 drivers/char/sonypi.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
index ccda997a9098..959949f04f7d 100644
--- a/drivers/char/sonypi.c
+++ b/drivers/char/sonypi.c
@@ -37,6 +37,7 @@
 #include <linux/kfifo.h>
 #include <linux/platform_device.h>
 #include <linux/gfp.h>
+#include <linux/string.h>
 #include <linux/string_choices.h>
 
 #include <linux/uaccess.h>
@@ -1120,8 +1121,8 @@ static int sonypi_acpi_probe(struct platform_device *pdev)
 	struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
 
 	sonypi_acpi_device = device;
-	strcpy(acpi_device_name(device), "Sony laptop hotkeys");
-	strcpy(acpi_device_class(device), "sony/hotkey");
+	strscpy(acpi_device_name(device), "Sony laptop hotkeys");
+	strscpy(acpi_device_class(device), "sony/hotkey");
 	return 0;
 }
 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-04-28 16:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-04-24  7:57 [PATCH] sonypi: use strscpy() in sonypi_acpi_probe Thorsten Blum
2026-04-24  8:34 ` Arnd Bergmann
2026-04-28 16:05 ` Ilpo Järvinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®