hwmon: (acpi_power_meter) Replace deprecated strcpy() with strscpy()

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>
Reviewed-by: lihuisong@huawei.com
Link: https://lore.kernel.org/r/20251220173041.377376-1-szymonwilczek@gmx.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
Szymon Wilczek 2025-12-20 18:30:41 +01:00 committed by Guenter Roeck
parent 246167b17c
commit d4168cb6ae

View File

@ -900,8 +900,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)