mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yacov Simhony <ysimhony@gmail.com>
To: jdelvare@suse.com, linux@roeck-us.net
Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org,
	Yacov Simhony <ysimhony@gmail.com>
Subject: [PATCH] hwmon: acpi_power_meter: replace deprecated strcpy() with strscpy()
Date: Mon, 14 Apr 2025 18:01:44 -0400	[thread overview]
Message-ID: <20250414220145.4111-1-ysimhony@gmail.com> (raw)

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@gmail.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


             reply	other threads:[~2025-04-14 22:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-14 22:01 Yacov Simhony [this message]
2025-04-14 22:41 ` Guenter Roeck
2025-12-20 17:30 [PATCH] hwmon: (acpi_power_meter) Replace " Szymon Wilczek
2025-12-23  1:31 ` lihuisong (C)
2026-01-12 21:27 ` 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=20250414220145.4111-1-ysimhony@gmail.com \
    --to=ysimhony@gmail.com \
    --cc=jdelvare@suse.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    /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®