mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Chen, Yu C" <yu.c.chen@intel.com>
To: "Thorsten Blum" <thorsten.blum@linux.dev>,
	"Hans de Goede" <hansg@kernel.org>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	"Maximilian Luz" <luzmaximilian@gmail.com>
Cc: <platform-driver-x86@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] platform/surface: Replace deprecated strcpy in surface_button_add
Date: Mon, 5 Jan 2026 20:52:26 +0800	[thread overview]
Message-ID: <4cadf166-2693-489e-a6f7-ae986694fd88@intel.com> (raw)
In-Reply-To: <20260105121802.1947-2-thorsten.blum@linux.dev>

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@linux.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;

  reply	other threads:[~2026-01-05 12:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-05 12:18 Thorsten Blum
2026-01-05 12:52 ` Chen, Yu C [this message]
2026-01-05 13:38   ` Thorsten Blum
2026-01-05 14:21     ` Ilpo Järvinen
2026-01-05 14:41       ` Chen, Yu C
2026-01-05 14:39     ` Chen, Yu C

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4cadf166-2693-489e-a6f7-ae986694fd88@intel.com \
    --to=yu.c.chen@intel.com \
    --cc=hansg@kernel.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luzmaximilian@gmail.com \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=thorsten.blum@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®