* [PATCH] ACPI / button: Add input_free_device() on registration failure
@ 2025-10-06 8:47 Kaushlendra Kumar
2025-10-22 19:21 ` Rafael J. Wysocki
0 siblings, 1 reply; 2+ messages in thread
From: Kaushlendra Kumar @ 2025-10-06 8:47 UTC (permalink / raw)
To: rafael, lenb; +Cc: linux-acpi, Kaushlendra Kumar
Add input_free_device() call when input_register_device() fails to
prevent memory leak. According to input_register_device() documentation,
"If function fails the device must be freed with input_free_device()",
but the current code only jumps to err_remove_fs without freeing the
allocated input device.
This ensures proper cleanup of the input device structure when device
registration encounters an error, preventing resource leaks in the ACPI
button driver.
Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
---
drivers/acpi/button.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index 0a7026040188..3c6dd9b4ba0a 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -619,8 +619,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:
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] ACPI / button: Add input_free_device() on registration failure
2025-10-06 8:47 [PATCH] ACPI / button: Add input_free_device() on registration failure Kaushlendra Kumar
@ 2025-10-22 19:21 ` Rafael J. Wysocki
0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2025-10-22 19:21 UTC (permalink / raw)
To: Kaushlendra Kumar; +Cc: rafael, lenb, linux-acpi
On Mon, Oct 6, 2025 at 10:49 AM Kaushlendra Kumar
<kaushlendra.kumar@intel.com> wrote:
>
> Add input_free_device() call when input_register_device() fails to
> prevent memory leak. According to input_register_device() documentation,
> "If function fails the device must be freed with input_free_device()",
> but the current code only jumps to err_remove_fs without freeing the
> allocated input device.
>
> This ensures proper cleanup of the input device structure when device
> registration encounters an error, preventing resource leaks in the ACPI
> button driver.
>
> Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
> ---
> drivers/acpi/button.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
> index 0a7026040188..3c6dd9b4ba0a 100644
> --- a/drivers/acpi/button.c
> +++ b/drivers/acpi/button.c
> @@ -619,8 +619,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:
> --
Applied as 6.18-rc material with rewritten subject and changelog, thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-10-22 19:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-06 8:47 [PATCH] ACPI / button: Add input_free_device() on registration failure Kaushlendra Kumar
2025-10-22 19:21 ` Rafael J. Wysocki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).