]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
sonypi: use strscpy() in sonypi_acpi_probe
authorThorsten Blum <thorsten.blum@linux.dev>
Fri, 24 Apr 2026 07:57:57 +0000 (09:57 +0200)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Tue, 28 Apr 2026 16:00:32 +0000 (19:00 +0300)
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>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Link: https://patch.msgid.link/20260424075755.305770-3-thorsten.blum@linux.dev
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
drivers/char/sonypi.c

index ccda997a9098a32d8207e7c5436db9ae0836494d..959949f04f7d98503d44117e45fe8ad83a3f3a0b 100644 (file)
@@ -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;
 }