Skip to content

Commit 7fcf82e

Browse files
qa-majeedrafaeljw
authored andcommitted
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: KSPP#88 Signed-off-by: Muhammad Qasim Abdul Majeed <[email protected]> Link: https://patch.msgid.link/[email protected] [ rjw: Subject and changelog edits ] Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 1b9c2e9 commit 7fcf82e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/acpi/button.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -547,20 +547,20 @@ static int acpi_button_add(struct acpi_device *device)
547547
!strcmp(hid, ACPI_BUTTON_HID_POWERF)) {
548548
button->type = ACPI_BUTTON_TYPE_POWER;
549549
handler = acpi_button_notify;
550-
strcpy(name, ACPI_BUTTON_DEVICE_NAME_POWER);
550+
strscpy(name, ACPI_BUTTON_DEVICE_NAME_POWER, MAX_ACPI_DEVICE_NAME_LEN);
551551
sprintf(class, "%s/%s",
552552
ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_POWER);
553553
} else if (!strcmp(hid, ACPI_BUTTON_HID_SLEEP) ||
554554
!strcmp(hid, ACPI_BUTTON_HID_SLEEPF)) {
555555
button->type = ACPI_BUTTON_TYPE_SLEEP;
556556
handler = acpi_button_notify;
557-
strcpy(name, ACPI_BUTTON_DEVICE_NAME_SLEEP);
557+
strscpy(name, ACPI_BUTTON_DEVICE_NAME_SLEEP, MAX_ACPI_DEVICE_NAME_LEN);
558558
sprintf(class, "%s/%s",
559559
ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_SLEEP);
560560
} else if (!strcmp(hid, ACPI_BUTTON_HID_LID)) {
561561
button->type = ACPI_BUTTON_TYPE_LID;
562562
handler = acpi_lid_notify;
563-
strcpy(name, ACPI_BUTTON_DEVICE_NAME_LID);
563+
strscpy(name, ACPI_BUTTON_DEVICE_NAME_LID, MAX_ACPI_DEVICE_NAME_LEN);
564564
sprintf(class, "%s/%s",
565565
ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_LID);
566566
input->open = acpi_lid_input_open;

0 commit comments

Comments
 (0)