Skip to content

Commit 5549202

Browse files
tiwaiij-intel
authored andcommitted
platform/x86: asus-wmi: Fix racy registrations
asus_wmi_register_driver() may be called from multiple drivers concurrently, which can lead to the racy list operations, eventually corrupting the memory and hitting Oops on some ASUS machines. Also, the error handling is missing, and it forgot to unregister ACPI lps0 dev ops in the error case. This patch covers those issues by introducing a simple mutex at acpi_wmi_register_driver() & *_unregister_driver, and adding the proper call of asus_s2idle_check_unregister() in the error path. Fixes: feea7bd ("platform/x86: asus-wmi: Refactor Ally suspend/resume") Link: https://bugzilla.suse.com/show_bug.cgi?id=1246924 Link: https://lore.kernel.org/[email protected] Signed-off-by: Takashi Iwai <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Ilpo Järvinen <[email protected]> Signed-off-by: Ilpo Järvinen <[email protected]>
1 parent c96f862 commit 5549202

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

drivers/platform/x86/asus-wmi.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5088,16 +5088,22 @@ static int asus_wmi_probe(struct platform_device *pdev)
50885088

50895089
asus_s2idle_check_register();
50905090

5091-
return asus_wmi_add(pdev);
5091+
ret = asus_wmi_add(pdev);
5092+
if (ret)
5093+
asus_s2idle_check_unregister();
5094+
5095+
return ret;
50925096
}
50935097

50945098
static bool used;
5099+
static DEFINE_MUTEX(register_mutex);
50955100

50965101
int __init_or_module asus_wmi_register_driver(struct asus_wmi_driver *driver)
50975102
{
50985103
struct platform_driver *platform_driver;
50995104
struct platform_device *platform_device;
51005105

5106+
guard(mutex)(&register_mutex);
51015107
if (used)
51025108
return -EBUSY;
51035109

@@ -5120,6 +5126,7 @@ EXPORT_SYMBOL_GPL(asus_wmi_register_driver);
51205126

51215127
void asus_wmi_unregister_driver(struct asus_wmi_driver *driver)
51225128
{
5129+
guard(mutex)(&register_mutex);
51235130
asus_s2idle_check_unregister();
51245131

51255132
platform_device_unregister(driver->platform_device);

0 commit comments

Comments
 (0)