[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240804123313.16211-5-qasim.majeed20@gmail.com>
Date: Sun, 4 Aug 2024 17:33:12 +0500
From: Muhammad Qasim Abdul Majeed <qasim.majeed20@...il.com>
To: rafael@...nel.org,
lenb@...nel.org,
linux-acpi@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: Muhammad Qasim Abdul Majeed <qasim.majeed20@...il.com>
Subject: [PATCH v2 5/6] ACPI: button: Use strscpy instead of strcpy.
Replace strcpy() with strscpy() in the ACPI button driver.
strcpy() has been deprecated because it is generally unsafe, so help to
eliminate it from the kernel source.
Link: https://github.com/KSPP/linux/issues/88
Signed-off-by: Muhammad Qasim Abdul Majeed <qasim.majeed20@...il.com>
---
drivers/acpi/button.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index cc61020756be..9dda4a3998f8 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -521,7 +521,7 @@ static int acpi_button_add(struct acpi_device *device)
struct input_dev *input;
const char *hid = acpi_device_hid(device);
acpi_status status;
- char *name, *class;
+ char *class;
int error = 0;
if (!strcmp(hid, ACPI_BUTTON_HID_LID) &&
@@ -540,27 +540,26 @@ static int acpi_button_add(struct acpi_device *device)
goto err_free_button;
}
- name = acpi_device_name(device);
class = acpi_device_class(device);
if (!strcmp(hid, ACPI_BUTTON_HID_POWER) ||
!strcmp(hid, ACPI_BUTTON_HID_POWERF)) {
button->type = ACPI_BUTTON_TYPE_POWER;
handler = acpi_button_notify;
- strcpy(name, ACPI_BUTTON_DEVICE_NAME_POWER);
+ strscpy(acpi_device_name(device), ACPI_BUTTON_DEVICE_NAME_POWER);
sprintf(class, "%s/%s",
ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_POWER);
} else if (!strcmp(hid, ACPI_BUTTON_HID_SLEEP) ||
!strcmp(hid, ACPI_BUTTON_HID_SLEEPF)) {
button->type = ACPI_BUTTON_TYPE_SLEEP;
handler = acpi_button_notify;
- strcpy(name, ACPI_BUTTON_DEVICE_NAME_SLEEP);
+ strscpy(acpi_device_name(device), ACPI_BUTTON_DEVICE_NAME_SLEEP);
sprintf(class, "%s/%s",
ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_SLEEP);
} else if (!strcmp(hid, ACPI_BUTTON_HID_LID)) {
button->type = ACPI_BUTTON_TYPE_LID;
handler = acpi_lid_notify;
- strcpy(name, ACPI_BUTTON_DEVICE_NAME_LID);
+ strscpy(acpi_device_name(device), ACPI_BUTTON_DEVICE_NAME_LID);
sprintf(class, "%s/%s",
ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_LID);
input->open = acpi_lid_input_open;
@@ -579,7 +578,7 @@ static int acpi_button_add(struct acpi_device *device)
snprintf(button->phys, sizeof(button->phys), "%s/button/input0", hid);
- input->name = name;
+ input->name = acpi_device_name(device);
input->phys = button->phys;
input->id.bustype = BUS_HOST;
input->id.product = button->type;
@@ -636,7 +635,7 @@ static int acpi_button_add(struct acpi_device *device)
}
device_init_wakeup(&device->dev, true);
- pr_info("%s [%s]\n", name, acpi_device_bid(device));
+ pr_info("%s [%s]\n", input->name, acpi_device_bid(device));
return 0;
err_input_unregister:
--
2.34.1
Powered by blists - more mailing lists