Hi Tim, On 10/29/21 17:07, Tim Crawford wrote: > Users on darp6 that do not have Open EC firmware have reported crashes > on boot. Correct the error handling for the input device to fix it. > > 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: 0de30fc684b ("platform/x86: system76_acpi: Replace Fn+F2 function for OLED models") > > Signed-off-by: Tim Crawford <tcrawford@xxxxxxxxxxxx> Since the device is allocated with devm_input_allocate_device() you also do not need to free it on input_register_device() error. As long as your probe() method exits with an error then the input_dev returned by devm_input_allocate_device() will be free-ed on return from probe() and it will also be unregistered if it was registered at the point of the error exit from probe(). (and like wise it will be automatically unregistered + free-ed on remove() following a successful probe()). So AFAICT all you need to do is drop the input_free_device() call from the "error:" exit path. Regards, Hans > --- > drivers/platform/x86/system76_acpi.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/drivers/platform/x86/system76_acpi.c b/drivers/platform/x86/system76_acpi.c > index b3c8178420b1..73232a543540 100644 > --- a/drivers/platform/x86/system76_acpi.c > +++ b/drivers/platform/x86/system76_acpi.c > @@ -715,8 +715,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) > @@ -739,7 +741,6 @@ static int system76_add(struct acpi_device *acpi_dev) > error: > kfree(data->ntmp); > kfree(data->nfan); > - input_free_device(data->input); > return err; > } > >