From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: "Miguel García" <miguelgarciaroman8@gmail.com>
Cc: platform-driver-x86@vger.kernel.org,
LKML <linux-kernel@vger.kernel.org>,
krzk@kernel.org
Subject: Re: [PATCH v3] platform/x86: surfacepro3_button: replace deprecated strcpy() with strscpy()
Date: Tue, 19 Aug 2025 13:00:27 +0300 (EEST) [thread overview]
Message-ID: <b6cb7905-8906-27eb-60a4-4475cd3f709a@linux.intel.com> (raw)
In-Reply-To: <20250728201135.584023-1-miguelgarciaroman8@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1617 bytes --]
On Mon, 28 Jul 2025, Miguel García wrote:
> Replace strcpy() with strscpy() when copying SURFACE_BUTTON_DEVICE_NAME
> into the device’s embedded name buffer returned by acpi_device_name().
> Bound the copy with MAX_ACPI_DEVICE_NAME_LEN to guarantee NUL-termination
> and avoid pointer-sized sizeof() mistakes.
>
> This is a mechanical safety improvement; functional behavior is unchanged.
>
> Signed-off-by: Miguel García <miguelgarciaroman8@gmail.com>
> ---
> v2:
> - Use MAX_ACPI_DEVICE_NAME_LEN instead of sizeof(name).
>
> v3:
> - Add full commit message (v2 was sent without message).
>
> Testing:
> - Build-tested on x86_64 (defconfig, allmodconfig, W=1).
> - No runtime testing on Surface hardware
>
> drivers/platform/surface/surfacepro3_button.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/platform/surface/surfacepro3_button.c b/drivers/platform/surface/surfacepro3_button.c
> index 2755601f979c..772e107151f6 100644
> --- a/drivers/platform/surface/surfacepro3_button.c
> +++ b/drivers/platform/surface/surfacepro3_button.c
> @@ -211,7 +211,7 @@ static int surface_button_add(struct acpi_device *device)
> }
>
> name = acpi_device_name(device);
> - strcpy(name, SURFACE_BUTTON_DEVICE_NAME);
> + strscpy(name, SURFACE_BUTTON_DEVICE_NAME, MAX_ACPI_DEVICE_NAME_LEN);
As mentioned earlier, I'd prefer this to use the two argument version of
strscpy():
strscpy(acpi_device_name(device), SURFACE_BUTTON_DEVICE_NAME);
...Changing to that may mean changes to name variable as well (remove
it?).
--
i.
next prev parent reply other threads:[~2025-08-19 10:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-24 7:45 [PATCH] " Miguel García
2025-07-27 20:32 ` Ilpo Järvinen
2025-07-28 1:47 ` Chen, Yu C
2025-07-28 5:30 ` Krzysztof Kozlowski
2025-07-28 19:49 ` [PATCH v2] " Miguel García
2025-07-28 20:11 ` [PATCH v3] " Miguel García
2025-08-19 10:00 ` Ilpo Järvinen [this message]
2025-07-29 7:38 ` [PATCH] " Miguel García Román
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=b6cb7905-8906-27eb-60a4-4475cd3f709a@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=krzk@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miguelgarciaroman8@gmail.com \
--cc=platform-driver-x86@vger.kernel.org \
/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®