commit:     89da65391ade80e805f022898bdc6234a5834e23
Author:     Arisu Tachibana <alicef <AT> gentoo <DOT> org>
AuthorDate: Thu Aug 28 16:37:29 2025 +0000
Commit:     Arisu Tachibana <alicef <AT> gentoo <DOT> org>
CommitDate: Thu Aug 28 16:37:29 2025 +0000
URL:        https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=89da6539

Add platform/x86: asus-wmi: Fix racy registrations

Signed-off-by: Arisu Tachibana <alicef <AT> gentoo.org>

 0000_README                                |  4 ++
 2700_asus-wmi_fix_racy_registrations.patch | 67 ++++++++++++++++++++++++++++++
 2 files changed, 71 insertions(+)

diff --git a/0000_README b/0000_README
index 4fe55656..5324b3e9 100644
--- a/0000_README
+++ b/0000_README
@@ -83,6 +83,10 @@ Patch:  
2010_ipv4_fix_regression_in_local-broadcast_routes.patch
 From:   
https://lore.kernel.org/regressions/[email protected]/
 Desc:   net: ipv4: fix regression in local-broadcast routes
 
+Patch:  2700_asus-wmi_fix_racy_registrations.patch
+From:   
https://lore.kernel.org/all/[email protected]/#Z31drivers:platform:x86:asus-wmi.c
+Desc:   platform/x86: asus-wmi: Fix racy registrations
+
 Patch:  2901_permit-menuconfig-sorting.patch
 From:   https://lore.kernel.org/
 Desc:   menuconfig: Allow sorting the entries alphabetically

diff --git a/2700_asus-wmi_fix_racy_registrations.patch 
b/2700_asus-wmi_fix_racy_registrations.patch
new file mode 100644
index 00000000..0e012eae
--- /dev/null
+++ b/2700_asus-wmi_fix_racy_registrations.patch
@@ -0,0 +1,67 @@
+Subject: [PATCH] platform/x86: asus-wmi: Fix racy registrations
+Date: Wed, 27 Aug 2025 07:24:33 +0200
+Message-ID: <[email protected]>
+X-Mailer: git-send-email 2.50.1
+X-Mailing-List: [email protected]
+List-Id: <platform-driver-x86.vger.kernel.org>
+List-Subscribe: <mailto:[email protected]>
+List-Unsubscribe: <mailto:[email protected]>
+
+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/[email protected]
+Signed-off-by: Takashi Iwai <[email protected]>
+---
+ 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)(&register_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)(&register_mutex);
+       asus_s2idle_check_unregister();
+ 
+       platform_device_unregister(driver->platform_device);
+-- 
+2.50.1
+
+

Reply via email to