From: "lihuisong (C)" <lihuisong@huawei.com>
To: Szymon Wilczek <szymonwilczek@gmx.com>, <linux@roeck-us.net>
Cc: <linux-hwmon@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] hwmon: (acpi_power_meter) Replace deprecated strcpy() with strscpy()
Date: Tue, 23 Dec 2025 09:31:00 +0800 [thread overview]
Message-ID: <09d98178-2621-47c1-ace8-b7b01e610367@huawei.com> (raw)
In-Reply-To: <20251220173041.377376-1-szymonwilczek@gmx.com>
在 2025/12/21 1:30, Szymon Wilczek 写道:
> strcpy() performs no bounds checking on the destination buffer, which
> could result in linear overflows beyond the end of the buffer. Although
> the source strings here are compile-time constants that fit within the
> destination buffers, using strscpy() is the preferred approach as it
> provides bounds checking and aligns with the kernel's deprecated API
> guidelines.
>
> This change converts the remaining strcpy() calls to strscpy(), matching
> the pattern already used throughout other ACPI drivers in
> drivers/acpi/*.c.
>
> Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy
> Signed-off-by: Szymon Wilczek <szymonwilczek@gmx.com>
> ---
> drivers/hwmon/acpi_power_meter.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
> index 29ccdc2fb7ff..cfb30c68bfc5 100644
> --- a/drivers/hwmon/acpi_power_meter.c
> +++ b/drivers/hwmon/acpi_power_meter.c
> @@ -890,8 +890,8 @@ static int acpi_power_meter_add(struct acpi_device *device)
> resource->sensors_valid = 0;
> resource->acpi_dev = device;
> mutex_init(&resource->lock);
> - strcpy(acpi_device_name(device), ACPI_POWER_METER_DEVICE_NAME);
> - strcpy(acpi_device_class(device), ACPI_POWER_METER_CLASS);
> + strscpy(acpi_device_name(device), ACPI_POWER_METER_DEVICE_NAME);
> + strscpy(acpi_device_class(device), ACPI_POWER_METER_CLASS);
> device->driver_data = resource;
>
> #if IS_REACHABLE(CONFIG_ACPI_IPMI)
LGTM,
Reviewed-by: lihuisong@huawei.com
next prev parent reply other threads:[~2025-12-23 1:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-20 17:30 Szymon Wilczek
2025-12-23 1:31 ` lihuisong (C) [this message]
2026-01-12 21:27 ` Guenter Roeck
-- strict thread matches above, loose matches on Subject: below --
2025-04-14 22:01 [PATCH] hwmon: acpi_power_meter: replace " Yacov Simhony
2025-04-14 22:41 ` Guenter Roeck
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=09d98178-2621-47c1-ace8-b7b01e610367@huawei.com \
--to=lihuisong@huawei.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=szymonwilczek@gmx.com \
/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®