diff mbox series

[RFC] ACPI / sysfs: Replace deprecated strcpy() with strscpy()

Message ID 20250616174748.2799-1-listout@listout.xyz
State New
Headers show
Series [RFC] ACPI / sysfs: Replace deprecated strcpy() with strscpy() | expand

Commit Message

Brahmajit Das June 16, 2025, 5:47 p.m. UTC
strcpy() is deprecated; use strscpy() instead. Use strscpy() to copy the
long name because there's no string to format with sprintf().

In the else clause we cannot use strscpy due to padding of
trace_method_name with '\', hence we can use other kernel safe string
functions such as scnprintf.

I'm not sure with the scnprintf, I would like some commet/s on that,
hence the RFC.

No functional changes intended.

Link: https://github.com/KSPP/linux/issues/88

Signed-off-by: Brahmajit Das <listout@listout.xyz>
---
 drivers/acpi/sysfs.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
index a48ebbf768f9..4005c9faf14f 100644
--- a/drivers/acpi/sysfs.c
+++ b/drivers/acpi/sysfs.c
@@ -181,10 +181,9 @@  static int param_set_trace_method_name(const char *val,
 
 	/* This is a hack.  We can't kmalloc in early boot. */
 	if (is_abs_path)
-		strcpy(trace_method_name, val);
+		strscpy(trace_method_name, val);
 	else {
-		trace_method_name[0] = '\\';
-		strcpy(trace_method_name+1, val);
+		scnprintf(trace_method_name, sizeof(trace_method_name), "%c%s", '\\', val);
 	}
 
 	/* Restore the original tracer state */