[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250414220145.4111-1-ysimhony@gmail.com>
Date: Mon, 14 Apr 2025 18:01:44 -0400
From: Yacov Simhony <ysimhony@...il.com>
To: jdelvare@...e.com,
linux@...ck-us.net
Cc: linux-hwmon@...r.kernel.org,
linux-kernel@...r.kernel.org,
Yacov Simhony <ysimhony@...il.com>
Subject: [PATCH] hwmon: acpi_power_meter: replace deprecated strcpy() with strscpy()
Use strscpy() instead of strcpy() to prevent potential buffer overflows
in acpi_device_name() and acpi_device_class(), which point to fixed-size
buffers.
This change improves safety and aligns with current kernel cleanup efforts.
Signed-off-by: Yacov Simhony <ysimhony@...il.com>
---
drivers/hwmon/acpi_power_meter.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
index 29ccdc2fb..a64497ddb 100644
--- a/drivers/hwmon/acpi_power_meter.c
+++ b/drivers/hwmon/acpi_power_meter.c
@@ -890,8 +890,12 @@ 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,
+ MAX_ACPI_DEVICE_NAME_LEN);
+ strscpy(acpi_device_class(device),
+ ACPI_POWER_METER_CLASS,
+ MAX_ACPI_CLASS_NAME_LEN);
device->driver_data = resource;
#if IS_REACHABLE(CONFIG_ACPI_IPMI)
--
2.47.0
Powered by blists - more mailing lists