ACPI: button: call input_free_device when input_register_device fails
PATCH 1/1 ACPI: button: call input_free_device when input_register_device fails
Call input_free_device when input_register_device fails.
Signed-off-by hongao <[email protected]>
drivers/acpi/button.c +3 -1
@@ -602,8 +602,10 @@ static int acpi_button_add(struct acpi_device *device)input_set_drvdata (input, device); error =input_register_device (input); -if (error) +if (error) { +input_free_device (input); goto err_remove_fs; + }switch (device->device_type) {case ACPI_BUS_TYPE_POWER_BUTTON :
base-commit: e5b3efbe1ab1793bb49ae07d56d0973267e65112
Signature · 1 line
2.33.1
Rafael J. Wysocki
maintainerQuoted 2 lines · hongao
Call
input_free_devicewheninput_register_devicefails.
And this is in order to address a memory leak, isn't it?
Quoted 7 lines
Signed-off-by hongao <[email protected]>drivers/acpi/button.c +0
-0
drivers/acpi/button.c static int acpi_button_add(struct acpi_device *device) · line 607
Quoted 7 lines
drivers/acpi/button.c +2
-1@@ -602,8 +602,10 @@ static int acpi_button_add(struct acpi_device *device)input_set_drvdata (input, device); error =input_register_device (input); -if (error) +if (error) { +input_free_device (input); goto err_remove_fs;
AFAICS, there is one other case in which something like this would need to be done and it's better to rearrange the error handling to cover all of these cases without duplicating input_free_device() calls.
Quoted 7 lines
drivers/acpi/button.c +1
-0+ }switch (device->device_type) {case ACPI_BUS_TYPE_POWER_BUTTON :base-commit:
e5b3efbe1ab1793bb49ae07d56d0973267e65112--