Skip to contentSkip to conversation

x86/olpc/xo15/sci: Replace strcpy with strscpy in xo15_sci_add

PATCH RESEND Applied Thorsten Blum 2 participants 2 messages Nov 24, 2025 – Jan 5 x86

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 x86/olpc/xo15/sci: Replace strcpy with strscpy in xo15_sci_add

strcpy() has been deprecated [1] because it performs no bounds checking on the destination buffer, which can lead to buffer overflows. Use the safer strscpy() instead.

---
Updated link and patch description.

---
 arch/x86/platform/olpc/olpc-xo15-sci.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
arch/x86/platform/olpc/olpc-xo15-sci.c +3 -2
index 68244a3422d1..82c51b6ec528 100644
@@ -7,6 +7,7 @@
 
 #include <linux/device.h>
 #include <linux/slab.h>
+#include <linux/string.h>
 #include <linux/workqueue.h>
 #include <linux/power_supply.h>
 #include <linux/olpc-ec.h>
@@ -144,8 +145,8 @@ static int xo15_sci_add(struct acpi_device *device)
 	if (!device)
 		return -EINVAL;
 
-	strcpy(acpi_device_name(device), XO15_SCI_DEVICE_NAME);
-	strcpy(acpi_device_class(device), XO15_SCI_CLASS);
+	strscpy(acpi_device_name(device), XO15_SCI_DEVICE_NAME);
+	strscpy(acpi_device_class(device), XO15_SCI_CLASS);
 
 	/* Get GPE bit assignment (EC events). */
 	status = acpi_evaluate_integer(device->handle, "_GPE", NULL, &tmp);
Signature · 1 line
2.51.1
merge bot Applied
#1 lore raw

[tip: x86/cleanups] x86/platform/olpc: Replace strcpy() with strscpy() in xo15_sci_add()

The following commit has been merged into the x86/cleanups branch of tip:

The following commit has been merged into the x86/cleanups branch of tip:

Commit-ID:     c957072d44a735ebbe8385fc3511a4f5e6ccea93
Gitweb:        https://git.kernel.org/tip/c957072d44a735ebbe8385fc3511a4f5e6ccea93
Author:        Thorsten Blum <[email protected]>
AuthorDate:    Mon, 24 Nov 2025 13:54:53 +01:00
Committer:     Borislav Petkov (AMD) <[email protected]>
CommitterDate: Mon, 05 Jan 2026 15:58:57 +01:00

x86/platform/olpc: Replace strcpy() with strscpy() in xo15_sci_add()

strcpy() has been deprecated¹ because it performs no bounds checking on the destination buffer, which can lead to buffer overflows. Use the safer strscpy() instead.

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

---
 arch/x86/platform/olpc/olpc-xo15-sci.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
arch/x86/platform/olpc/olpc-xo15-sci.c +3 -2
index 68244a3..82c51b6 100644
@@ -7,6 +7,7 @@
 
 #include <linux/device.h>
 #include <linux/slab.h>
+#include <linux/string.h>
 #include <linux/workqueue.h>
 #include <linux/power_supply.h>
 #include <linux/olpc-ec.h>
@@ -144,8 +145,8 @@ static int xo15_sci_add(struct acpi_device *device)
 	if (!device)
 		return -EINVAL;
 
-	strcpy(acpi_device_name(device), XO15_SCI_DEVICE_NAME);
-	strcpy(acpi_device_class(device), XO15_SCI_CLASS);
+	strscpy(acpi_device_name(device), XO15_SCI_DEVICE_NAME);
+	strscpy(acpi_device_class(device), XO15_SCI_CLASS);
 
 	/* Get GPE bit assignment (EC events). */
 	status = acpi_evaluate_integer(device->handle, "_GPE", NULL, &tmp);