ACPI: ac: Use strscpy() instead of strcpy().
Subsystems (2)
PATCH v2 1/6 ACPI: ac: Use strscpy() instead of strcpy().
Replace strcpy() with strscpy() in the ACPI ac driver. strcpy() has been deprecated because it is generally unsafe, so help to eliminate it from the kernel source.
--- drivers/acpi/ac.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/acpi/ac.c +2 -2
@@ -213,8 +213,8 @@ static int acpi_ac_probe(struct platform_device *pdev)return -ENOMEM ; ac->device = adev; -strcpy (acpi_device_name (adev),ACPI_AC_DEVICE_NAME ); -strcpy (acpi_device_class (adev),ACPI_AC_CLASS ); +strscpy (acpi_device_name (adev),ACPI_AC_DEVICE_NAME ); +strscpy (acpi_device_class (adev),ACPI_AC_CLASS );platform_set_drvdata (pdev, ac);
Signature · 1 line
2.34.1
PATCH v2 2/6 ACPI: acpi_pad: Use strscpy instead of strcpy.
Replace strcpy() with strscpy() in the ACPI acpi_pad driver. strcpy() has been deprecated because it is generally unsafe, so help to eliminate it from the kernel source.
--- drivers/acpi/acpi_pad.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/acpi/acpi_pad.c +2 -2
@@ -417,8 +417,8 @@ static int acpi_pad_probe(struct platform_device *pdev)struct acpi_device *adev =ACPI_COMPANION (&pdev->dev);acpi_status status; -strcpy (acpi_device_name (adev),ACPI_PROCESSOR_AGGREGATOR_DEVICE_NAME ); -strcpy (acpi_device_class (adev),ACPI_PROCESSOR_AGGREGATOR_CLASS ); +strscpy (acpi_device_name (adev),ACPI_PROCESSOR_AGGREGATOR_DEVICE_NAME ); +strscpy (acpi_device_class (adev),ACPI_PROCESSOR_AGGREGATOR_CLASS ); status =acpi_install_notify_handler (adev->handle,ACPI_DEVICE_NOTIFY , acpi_pad_notify, adev);
Signature · 1 line
2.34.1
PATCH v2 3/6 ACPI: acpi_processor: Use strscpy instead of strcpy.
In reply to Muhammad Qasim Abdul MajeedReplace strcpy() with strscpy() in the ACPI acpi_processor driver. strcpy() has been deprecated because it is generally unsafe, so help to eliminate it from the kernel source.
--- drivers/acpi/acpi_processor.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/acpi/acpi_processor.c +2 -2
@@ -394,8 +394,8 @@ static int acpi_processor_add(struct acpi_device *device, } pr->handle = device->handle; -strcpy (acpi_device_name (device),ACPI_PROCESSOR_DEVICE_NAME ); -strcpy (acpi_device_class (device),ACPI_PROCESSOR_CLASS ); +strscpy (acpi_device_name (device),ACPI_PROCESSOR_DEVICE_NAME ); +strscpy (acpi_device_class (device),ACPI_PROCESSOR_CLASS ); device->driver_data = pr; result =acpi_processor_get_info (device);
Signature · 1 line
2.34.1
PATCH v2 4/6 ACPI: battery : Use strscpy instead of strcpy.
In reply to Muhammad Qasim Abdul MajeedReplace strcpy() with strscpy() in the ACPI battery driver. strcpy() has been deprecated because it is generally unsafe, so help to eliminate it from the kernel source.
--- drivers/acpi/battery.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/acpi/battery.c +2 -2
@@ -1193,8 +1193,8 @@ static int acpi_battery_add(struct acpi_device *device)if (!battery)return -ENOMEM ; battery->device = device; -strcpy (acpi_device_name (device),ACPI_BATTERY_DEVICE_NAME ); -strcpy (acpi_device_class (device),ACPI_BATTERY_CLASS ); +strscpy (acpi_device_name (device),ACPI_BATTERY_DEVICE_NAME ); +strscpy (acpi_device_class (device),ACPI_BATTERY_CLASS ); device->driver_data = battery;mutex_init (&battery->lock);mutex_init (&battery->sysfs_lock);
Signature · 1 line
2.34.1
PATCH v2 5/6 ACPI: button: Use strscpy instead of strcpy.
In reply to Muhammad Qasim Abdul MajeedReplace 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.
--- drivers/acpi/button.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/acpi/button.c +6 -7
@@ -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:
Signature · 1 line
2.34.1
Rafael J. Wysocki
maintainerRe: [PATCH v2 5/6] ACPI: button: Use strscpy instead of strcpy.
Quoted 27 lines · Muhammad Qasim Abdul Majeed
Replace
strcpy()withstrscpy()in the ACPI button driver.
strcpy()has been deprecated because it is generally unsafe, so help to eliminate it from the kernel source.Signed-off-by Muhammad Qasim Abdul Majeed <[email protected]>--- drivers/acpi/button.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)drivers/acpi/button.c +1
-1@@ -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) &&
drivers/acpi/button.c static int acpi_button_add(struct acpi_device *device) · line 543
Quoted 4 lines
drivers/acpi/button.c +0
-1@@ -540,27 +540,26 @@ static int acpi_button_add(struct acpi_device *device) goto err_free_button; } - name =acpi_device_name (device);
This is more than advertised in the changelog.
Please extend the changelog to explain why this additional change is needed.
Quoted 47 lines
drivers/acpi/button.c +5
-6class =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
PATCH v2 6/6 ACPI: bus: Define and use a macro for device and class name length.
In reply to Muhammad Qasim Abdul Majeed--- include/acpi/acpi_bus.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
include/acpi/acpi_bus.h +4 -3
@@ -226,11 +226,12 @@ struct acpi_device_dir {#define acpi_device_dir (d) ((d)->dir.entry)/* Plug and Play */ - +#define MAX_ACPI_DEVICE_NAME_LEN 40 +#define MAX_ACPI_CLASS_NAME_LEN 20typedef char acpi_bus_id [8 ];typedef u64 acpi_bus_address ; -typedef char acpi_device_name [40 ]; -typedef char acpi_device_class [20 ]; +typedef char acpi_device_name [MAX_ACPI_DEVICE_NAME_LEN ]; +typedef char acpi_device_class [MAX_ACPI_CLASS_NAME_LEN ];struct acpi_hardware_id {struct list_head list;
Signature · 1 line
2.34.1
Quoted 18 lines · Muhammad Qasim Abdul Majeed
Replace
strcpy()withstrscpy()in the ACPI ac driver.strcpy()has been deprecated because it is generally unsafe, so help to eliminate it from the kernel source.Signed-off-by Muhammad Qasim Abdul Majeed <[email protected]>--- drivers/acpi/ac.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/acpi/ac.c +0
-0@@ -213,8 +213,8 @@ static int acpi_ac_probe(struct platform_device *pdev)return -ENOMEM ;
drivers/acpi/ac.c static int acpi_ac_probe(struct platform_device *pdev)
Quoted 10 lines
drivers/acpi/ac.c +2
-3ac->device = adev; -strcpy (acpi_device_name (adev),ACPI_AC_DEVICE_NAME ); -strcpy (acpi_device_class (adev),ACPI_AC_CLASS ); +strscpy (acpi_device_name (adev),ACPI_AC_DEVICE_NAME ); +strscpy (acpi_device_class (adev),ACPI_AC_CLASS );platform_set_drvdata (pdev, ac); --
Applied as 6.12 material with some subject and changelog edits along with patches [2-4/6] and [6/6].
Patch [6/6] needs more work (I'll send a reply to it directly).
Thanks!