Skip to contentSkip to conversation

platform/x86: dell-smbios-wmi: Fix oops on rmmod dell_smbios

PATCH In review Hans de Goede 2 participants 4 messages May 18, 2021 – May 19, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 platform/x86: dell-smbios-wmi: Fix oops on rmmod dell_smbios

init_dell_smbios_wmi() only registers the dell_smbios_wmi_driver on systems where the Dell WMI interface is support. While exit_dell_smbios_wmi() unregisters it unconditionally, this leads to the following oops:

[  175.722921] ------------[ cut here ]------------
[  175.722925] Unexpected driver unregister!
[  175.722939] WARNING: CPU: 1 PID: 3630 at drivers/base/driver.c:194 driver_unregister+0x38/0x40
...
[  175.723089] Call Trace:
[  175.723094]  cleanup_module+0x5/0xedd [dell_smbios]
...
[  175.723148] ---[ end trace 064c34e1ad49509d ]---

Make the unregister happen on the same condition the register happens to fix this.

Cc Mario Limonciello <[email protected]>
Fixes 1a258e670434 ("platform/x86: dell-smbios-wmi: Add new WMI dispatcher driver")
---
 drivers/platform/x86/dell/dell-smbios-wmi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/platform/x86/dell/dell-smbios-wmi.c +2 -1
index a1753485159c..33f823772733 100644
@@ -270,7 +270,8 @@ int init_dell_smbios_wmi(void)
 
 void exit_dell_smbios_wmi(void)
 {
-	wmi_driver_unregister(&dell_smbios_wmi_driver);
+	if (wmi_supported)
+		wmi_driver_unregister(&dell_smbios_wmi_driver);
 }
 
 MODULE_DEVICE_TABLE(wmi, dell_smbios_wmi_id_table);
Signature · 1 line
2.31.1
#1 lore raw
Quoted 28 lines · Hans de Goede

init_dell_smbios_wmi() only registers the dell_smbios_wmi_driver on systems where the Dell WMI interface is support. While exit_dell_smbios_wmi() unregisters it unconditionally, this leads to the following oops:

[  175.722921] ------------[ cut here ]------------
[  175.722925] Unexpected driver unregister!
[  175.722939] WARNING: CPU: 1 PID: 3630 at drivers/base/driver.c:194 driver_unregister+0x38/0x40
...
[  175.723089] Call Trace:
[  175.723094]  cleanup_module+0x5/0xedd [dell_smbios]
...
[  175.723148] ---[ end trace 064c34e1ad49509d ]---

Make the unregister happen on the same condition the register happens to fix this.

Cc Mario Limonciello <[email protected]>
Fixes 1a258e670434 ("platform/x86: dell-smbios-wmi: Add new WMI dispatcher driver")
---
 drivers/platform/x86/dell/dell-smbios-wmi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/platform/x86/dell/dell-smbios-wmi.c +0 -0
index a1753485159c..33f823772733 100644

drivers/platform/x86/dell/dell-smbios-wmi.c int init_dell_smbios_wmi(void) · line 273

Quoted 5 lines
drivers/platform/x86/dell/dell-smbios-wmi.c +1 -1
@@ -270,7 +270,8 @@ int init_dell_smbios_wmi(void)
 
 void exit_dell_smbios_wmi(void)
 {
-	wmi_driver_unregister(&dell_smbios_wmi_driver);
+	if (wmi_supported)

Something is fishy with this. wmi_supported is used in the init_dell_smbios_wmi function so we shouldn't even be able to call this function if wmi_supported == 0

is there a bug in the wmi framework where drivers that fail to init are not removed from a list resulting in a failure to unregister? Is your fix hiding a higher level issue?

Looking more shouldn't the prob function NOT get called if the init function fails?

--mark

Quoted 7 lines
drivers/platform/x86/dell/dell-smbios-wmi.c +1 -0
+		wmi_driver_unregister(&dell_smbios_wmi_driver);
 }
 
 MODULE_DEVICE_TABLE(wmi, dell_smbios_wmi_id_table);
Signature · 1 line
2.31.1
Reviewed-by
#2 lore raw
Quoted 38 lines · mark gross
Quoted 28 lines · Hans de Goede

init_dell_smbios_wmi() only registers the dell_smbios_wmi_driver on systems where the Dell WMI interface is support. While exit_dell_smbios_wmi() unregisters it unconditionally, this leads to the following oops:

[  175.722921] ------------[ cut here ]------------
[  175.722925] Unexpected driver unregister!
[  175.722939] WARNING: CPU: 1 PID: 3630 at drivers/base/driver.c:194 driver_unregister+0x38/0x40
...
[  175.723089] Call Trace:
[  175.723094]  cleanup_module+0x5/0xedd [dell_smbios]
...
[  175.723148] ---[ end trace 064c34e1ad49509d ]---

Make the unregister happen on the same condition the register happens to fix this.

Cc Mario Limonciello <[email protected]>
Fixes 1a258e670434 ("platform/x86: dell-smbios-wmi: Add new WMI dispatcher driver")
---
 drivers/platform/x86/dell/dell-smbios-wmi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/platform/x86/dell/dell-smbios-wmi.c +0 -0
index a1753485159c..33f823772733 100644

drivers/platform/x86/dell/dell-smbios-wmi.c int init_dell_smbios_wmi(void) · line 273

Quoted 5 lines
drivers/platform/x86/dell/dell-smbios-wmi.c +1 -1
@@ -270,7 +270,8 @@ int init_dell_smbios_wmi(void)
 
 void exit_dell_smbios_wmi(void)
 {
-	wmi_driver_unregister(&dell_smbios_wmi_driver);
+	if (wmi_supported)

Something is fishy with this. wmi_supported is used in the init_dell_smbios_wmi function so we shouldn't even be able to call this function if wmi_supported == 0

Quoted 6 lines

is there a bug in the wmi framework where drivers that fail to init are not removed from a list resulting in a failure to unregister? Is your fix hiding a higher level issue?

Looking more shouldn't the prob function NOT get called if the init function fails?

Never mind. After thinking it over this fix makes sence the init and exit functions get called regardless of registering.

the fix looks good.

--mrak

Quoted 8 lines
Quoted 8 lines
drivers/platform/x86/dell/dell-smbios-wmi.c +1 -0
+		wmi_driver_unregister(&dell_smbios_wmi_driver);
 }
 
 MODULE_DEVICE_TABLE(wmi, dell_smbios_wmi_id_table);
Signature · 1 line
2.31.1
#3 lore raw
In reply to Hans de Goede

Hi all,

Quoted 13 lines · Hans de Goede

init_dell_smbios_wmi() only registers the dell_smbios_wmi_driver on systems where the Dell WMI interface is support. While exit_dell_smbios_wmi() unregisters it unconditionally, this leads to the following oops:

[  175.722921] ------------[ cut here ]------------
[  175.722925] Unexpected driver unregister!
[  175.722939] WARNING: CPU: 1 PID: 3630 at drivers/base/driver.c:194 driver_unregister+0x38/0x40
...
[  175.723089] Call Trace:
[  175.723094]  cleanup_module+0x5/0xedd [dell_smbios]
...
[  175.723148] ---[ end trace 064c34e1ad49509d ]---
Quoted 6 lines

Make the unregister happen on the same condition the register happens to fix this.

Cc Mario Limonciello <[email protected]>
Fixes 1a258e670434 ("platform/x86: dell-smbios-wmi: Add new WMI dispatcher driver")

I've added this to my review-hans branch now and I will also include this in the next pdx86-fixes pull-req for 5.13.

Regards,

Hans

Quoted 19 lines
---
 drivers/platform/x86/dell/dell-smbios-wmi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/platform/x86/dell/dell-smbios-wmi.c +2 -1
index a1753485159c..33f823772733 100644
@@ -270,7 +270,8 @@ int init_dell_smbios_wmi(void)
 
 void exit_dell_smbios_wmi(void)
 {
-	wmi_driver_unregister(&dell_smbios_wmi_driver);
+	if (wmi_supported)
+		wmi_driver_unregister(&dell_smbios_wmi_driver);
 }
 
 MODULE_DEVICE_TABLE(wmi, dell_smbios_wmi_id_table);