* [PATCH] platform/x86: asus-wmi: Fix racy registrations
@ 2025-08-27 5:24 Takashi Iwai
2025-08-28 16:20 ` Ilpo Järvinen
2025-08-30 1:38 ` Stefan Lippers-Hollmann
0 siblings, 2 replies; 3+ messages in thread
From: Takashi Iwai @ 2025-08-27 5:24 UTC (permalink / raw)
To: Luke D . Jones
Cc: Corentin Chary, Hans de Goede, Ilpo Järvinen, Jiri Slaby,
platform-driver-x86, linux-kernel
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: feea7bd6b02d ("platform/x86: asus-wmi: Refactor Ally suspend/resume")
Link: https://bugzilla.suse.com/show_bug.cgi?id=1246924
Link: https://lore.kernel.org/07815053-0e31-4e8e-8049-b652c929323b@kernel.org
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
drivers/platform/x86/asus-wmi.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index f7191fdded14..e72a2b5d158e 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -5088,16 +5088,22 @@ static int asus_wmi_probe(struct platform_device *pdev)
asus_s2idle_check_register();
- return asus_wmi_add(pdev);
+ ret = asus_wmi_add(pdev);
+ if (ret)
+ asus_s2idle_check_unregister();
+
+ return ret;
}
static bool used;
+static DEFINE_MUTEX(register_mutex);
int __init_or_module asus_wmi_register_driver(struct asus_wmi_driver *driver)
{
struct platform_driver *platform_driver;
struct platform_device *platform_device;
+ guard(mutex)(®ister_mutex);
if (used)
return -EBUSY;
@@ -5120,6 +5126,7 @@ EXPORT_SYMBOL_GPL(asus_wmi_register_driver);
void asus_wmi_unregister_driver(struct asus_wmi_driver *driver)
{
+ guard(mutex)(®ister_mutex);
asus_s2idle_check_unregister();
platform_device_unregister(driver->platform_device);
--
2.50.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] platform/x86: asus-wmi: Fix racy registrations
2025-08-27 5:24 [PATCH] platform/x86: asus-wmi: Fix racy registrations Takashi Iwai
@ 2025-08-28 16:20 ` Ilpo Järvinen
2025-08-30 1:38 ` Stefan Lippers-Hollmann
1 sibling, 0 replies; 3+ messages in thread
From: Ilpo Järvinen @ 2025-08-28 16:20 UTC (permalink / raw)
To: Luke D . Jones, Takashi Iwai
Cc: Corentin Chary, Hans de Goede, Jiri Slaby, platform-driver-x86,
linux-kernel
On Wed, 27 Aug 2025 07:24:33 +0200, Takashi Iwai wrote:
> 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.
>
> [...]
Thank you for your contribution, it has been applied to my local
review-ilpo-fixes branch. Note it will show up in the public
platform-drivers-x86/review-ilpo-fixes branch only once I've pushed my
local branch there, which might take a while.
The list of commits applied:
[1/1] platform/x86: asus-wmi: Fix racy registrations
commit: 5549202b9c02c2ecbc8634768a3da8d9e82d548d
--
i.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] platform/x86: asus-wmi: Fix racy registrations
2025-08-27 5:24 [PATCH] platform/x86: asus-wmi: Fix racy registrations Takashi Iwai
2025-08-28 16:20 ` Ilpo Järvinen
@ 2025-08-30 1:38 ` Stefan Lippers-Hollmann
1 sibling, 0 replies; 3+ messages in thread
From: Stefan Lippers-Hollmann @ 2025-08-30 1:38 UTC (permalink / raw)
To: Takashi Iwai
Cc: Luke D . Jones, Corentin Chary, Hans de Goede, Ilpo Järvinen,
Jiri Slaby, platform-driver-x86, linux-kernel
Hi
On 2025-08-27, Takashi Iwai wrote:
> 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.
[...]
Thank you very much for this patch, it fixes the v6.16.x regression for
me (my own git bisecting failed more than four times, due to false
negatives) :)
Confirmed to work on:
- ASUS PRIME B760M-A WIFI D4, i7-13700
- ASUS TUF GAMING B760M-PLUS WIFI D4, i5-12400
Regards
Stefan Lippers-Hollmann
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-08-30 1:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-27 5:24 [PATCH] platform/x86: asus-wmi: Fix racy registrations Takashi Iwai
2025-08-28 16:20 ` Ilpo Järvinen
2025-08-30 1:38 ` Stefan Lippers-Hollmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).