Re: [pdx86-platform-drivers-x86:for-next 31/36] drivers/platform/x86/thinkpad_acpi.c:11154 thinkpad_acpi_module_exit() error: don't call input_free_device() after input_unregister_device()

From: Hans de Goede
Date: Thu Dec 02 2021 - 06:59:33 EST


Hi Dan,

On 11/30/21 09:05, Dan Carpenter wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git for-next
> head: e9ff190973df2c417c2a97a8b70e709e0bdc2716
> commit: 67e7d50d13e94abeaf82e9945dce929352771b94 [31/36] platform/x86: thinkpad_acpi: Move input_unregister_device() to the top of thinkpad_acpi_module_exit()
> config: i386-randconfig-m021-20211129 (https://download.01.org/0day-ci/archive/20211129/202111292341.pt8nIc7T-lkp@xxxxxxxxx/config)
> compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@xxxxxxxxx>
> Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
>
> New smatch warnings:
> drivers/platform/x86/thinkpad_acpi.c:11154 thinkpad_acpi_module_exit() error: don't call input_free_device() after input_unregister_device()
>
> vim +11154 drivers/platform/x86/thinkpad_acpi.c
>
> b21a15f6d065e83 drivers/misc/thinkpad_acpi.c Henrique de Moraes Holschuh 2008-01-08 11130 static void thinkpad_acpi_module_exit(void)
> b21a15f6d065e83 drivers/misc/thinkpad_acpi.c Henrique de Moraes Holschuh 2008-01-08 11131 {
> b21a15f6d065e83 drivers/misc/thinkpad_acpi.c Henrique de Moraes Holschuh 2008-01-08 11132 struct ibm_struct *ibm, *itmp;
> b21a15f6d065e83 drivers/misc/thinkpad_acpi.c Henrique de Moraes Holschuh 2008-01-08 11133
> b21a15f6d065e83 drivers/misc/thinkpad_acpi.c Henrique de Moraes Holschuh 2008-01-08 11134 tpacpi_lifecycle = TPACPI_LIFE_EXITING;
> b21a15f6d065e83 drivers/misc/thinkpad_acpi.c Henrique de Moraes Holschuh 2008-01-08 11135
> 67e7d50d13e94ab drivers/platform/x86/thinkpad_acpi.c Hans de Goede 2021-11-23 11136 if (tp_features.input_device_registered)
> 67e7d50d13e94ab drivers/platform/x86/thinkpad_acpi.c Hans de Goede 2021-11-23 11137 input_unregister_device(tpacpi_inputdev);
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> 526ac103dbc6729 drivers/platform/x86/thinkpad_acpi.c Hans de Goede 2021-11-23 11138 if (tpacpi_hwmon)
> 526ac103dbc6729 drivers/platform/x86/thinkpad_acpi.c Hans de Goede 2021-11-23 11139 hwmon_device_unregister(tpacpi_hwmon);
> 2f5ad08f3eec8d4 drivers/platform/x86/thinkpad_acpi.c Hans de Goede 2021-11-23 11140 if (tp_features.sensors_pdrv_registered)
> 2f5ad08f3eec8d4 drivers/platform/x86/thinkpad_acpi.c Hans de Goede 2021-11-23 11141 platform_driver_unregister(&tpacpi_hwmon_pdriver);
> 2f5ad08f3eec8d4 drivers/platform/x86/thinkpad_acpi.c Hans de Goede 2021-11-23 11142 if (tp_features.platform_drv_registered)
> 2f5ad08f3eec8d4 drivers/platform/x86/thinkpad_acpi.c Hans de Goede 2021-11-23 11143 platform_driver_unregister(&tpacpi_pdriver);
> 2f5ad08f3eec8d4 drivers/platform/x86/thinkpad_acpi.c Hans de Goede 2021-11-23 11144
> b21a15f6d065e83 drivers/misc/thinkpad_acpi.c Henrique de Moraes Holschuh 2008-01-08 11145 list_for_each_entry_safe_reverse(ibm, itmp,
> b21a15f6d065e83 drivers/misc/thinkpad_acpi.c Henrique de Moraes Holschuh 2008-01-08 11146 &tpacpi_all_drivers,
> b21a15f6d065e83 drivers/misc/thinkpad_acpi.c Henrique de Moraes Holschuh 2008-01-08 11147 all_drivers) {
> b21a15f6d065e83 drivers/misc/thinkpad_acpi.c Henrique de Moraes Holschuh 2008-01-08 11148 ibm_exit(ibm);
> b21a15f6d065e83 drivers/misc/thinkpad_acpi.c Henrique de Moraes Holschuh 2008-01-08 11149 }
> b21a15f6d065e83 drivers/misc/thinkpad_acpi.c Henrique de Moraes Holschuh 2008-01-08 11150
> b21a15f6d065e83 drivers/misc/thinkpad_acpi.c Henrique de Moraes Holschuh 2008-01-08 11151 dbg_printk(TPACPI_DBG_INIT, "finished subdriver exit path...\n");
> b21a15f6d065e83 drivers/misc/thinkpad_acpi.c Henrique de Moraes Holschuh 2008-01-08 11152
> 67e7d50d13e94ab drivers/platform/x86/thinkpad_acpi.c Hans de Goede 2021-11-23 11153 if (tpacpi_inputdev)
> b21a15f6d065e83 drivers/misc/thinkpad_acpi.c Henrique de Moraes Holschuh 2008-01-08 @11154 input_free_device(tpacpi_inputdev);
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> I haven't seen this warning in a long time, so I forget why it exists.
> But apparently it's against the rules. :P

Yes, this is my bad. I've dropped this cleanup patch from the pdx86 for-next branch now,
since clearly this is a bad idea.

Thank you for catching this.

Regards,

Hans