[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4cadf166-2693-489e-a6f7-ae986694fd88@intel.com>
Date: Mon, 5 Jan 2026 20:52:26 +0800
From: "Chen, Yu C" <yu.c.chen@...el.com>
To: Thorsten Blum <thorsten.blum@...ux.dev>, Hans de Goede <hansg@...nel.org>,
Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>, "Maximilian
Luz" <luzmaximilian@...il.com>
CC: <platform-driver-x86@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] platform/surface: Replace deprecated strcpy in
surface_button_add
Hi Thorsten,
On 1/5/2026 8:18 PM, Thorsten Blum wrote:
> strcpy() has been deprecated [1] because it performs no bounds checking
> on the destination buffer, which can lead to buffer overflows. Replace
> it with the safer strscpy(). No functional changes.
>
> Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy [1]
> Signed-off-by: Thorsten Blum <thorsten.blum@...ux.dev>
> ---
> drivers/platform/surface/surfacepro3_button.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/platform/surface/surfacepro3_button.c b/drivers/platform/surface/surfacepro3_button.c
> index 2755601f979c..d027a064a62d 100644
> --- a/drivers/platform/surface/surfacepro3_button.c
> +++ b/drivers/platform/surface/surfacepro3_button.c
> @@ -10,6 +10,7 @@
> #include <linux/kernel.h>
> #include <linux/module.h>
> #include <linux/init.h>
> +#include <linux/string.h>
> #include <linux/types.h>
> #include <linux/input.h>
> #include <linux/acpi.h>
> @@ -211,7 +212,7 @@ static int surface_button_add(struct acpi_device *device)
> }
>
> name = acpi_device_name(device);
> - strcpy(name, SURFACE_BUTTON_DEVICE_NAME);
> + strscpy(acpi_device_name(device), SURFACE_BUTTON_DEVICE_NAME);
Thanks for the fix, a minor question might be why we do not reuse
name by strscpy(name, SURFACE_BUTTON_DEVICE_NAME) ?
thanks,
Chenyu
> snprintf(button->phys, sizeof(button->phys), "%s/buttons", hid);
>
> input->name = name;
Powered by blists - more mailing lists