Szymon Wilczek

research / torvalds/linux / hwmon / d4168cb6ae4f

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

torvalds/linux

hwmon +2 −2

From: Szymon Wilczek <[email protected]>
Date: 20 Dec 2025
Subject: [PATCH] hwmon: (acpi_power_meter) Replace deprecated strcpy() with strscpy()
Merged: 31 Jan 2026, by Guenter Roeck

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.

signed, reported, fixes

  • Signed-off-by Szymon Wilczek author
  • Reviewed-by lihuisong reviewed it
  • Signed-off-by Guenter Roeck maintainer · merged it

diff

drivers/hwmon/acpi_power_meter.c +2 −2
@@ -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)

discussion · on the list

v1 · 5 messages

Yacov Simhony reviewer 14 Apr 2025

[PATCH] hwmon: acpi_power_meter: replace deprecated strcpy() with strscpy()

Guenter Roeck maintainer 14 Apr 2025

ACPI_POWER_METER_DEVICE_NAME and ACPI_POWER_METER_CLASS are constant strings. There is no danger of buffer overflows. There is no safety improvement. We should concentrate on fixing real problems, not imaginary ones. Guenter

Szymon Wilczek author 20 Dec 2025

[PATCH] hwmon: (acpi_power_meter) Replace deprecated strcpy() with strscpy()

applied

Guenter Roeck maintainer 12 Jan 2026

Applied. Thanks, Guenter
the whole thread on lore.kernel.org
12/12
salina
aurum
herbarium
mysterium
parchment
whispergrove
M-x 0/0

keybindings & navigation

M-x / Alt+x Open Emacs command runner
Shift + W Jump to writings & essays (/writings)
Shift + R Jump to research & upstream work (/research)
Shift + T Choose colour theme (au-themes-select)
j / k Scroll down / up
g g Scroll to the top of page
Shift + G Scroll to the bottom of page
? Toggle this keybindings help cheat sheet
Esc / C-g Dismiss modal or close active menu