From b49caa557e6f902381ca76b6bb8f8a2825ad099b Mon Sep 17 00:00:00 2001 From: Tim Crawford Date: Thu, 28 Oct 2021 17:06:48 -0600 Subject: [PATCH] Fix error handling for input device input_free_device only needs to be called if input_register_device failed, not in all error cases. Per devm_input_allocate_device documentation, managed devices do not need to be explicitly unregistered or freed, so do not add any other cleanup for the device. Fixes: c169971892d ("Address feedback from upstream") Signed-off-by: Tim Crawford --- system76_acpi.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/system76_acpi.c b/system76_acpi.c index 35dedf3..84273a1 100644 --- a/system76_acpi.c +++ b/system76_acpi.c @@ -732,8 +732,10 @@ static int system76_add(struct acpi_device *acpi_dev) input_set_capability(data->input, EV_KEY, KEY_SCREENLOCK); err = input_register_device(data->input); - if (err) - goto error; + if (err) { + input_free_device(data->input); + return err; + } err = system76_get_object(data, "NFAN", &data->nfan); if (err) @@ -756,7 +758,6 @@ static int system76_add(struct acpi_device *acpi_dev) error: kfree(data->ntmp); kfree(data->nfan); - input_free_device(data->input); return err; }