Skip to contentSkip to conversation

platform/x86: Fix fiwmare_attributes_class device unregistration

PATCH In review Kurt Borja 2 participants 5 messages Jun 26, 2025 – Jun 30, 2025

Subsystems (5)
lore
Share & tools
lore

Kurt Borja

author
#0 lore raw

cover platform/x86: Fix fiwmare_attributes_class device unregistration

Hi all,

Using device_destroy() for unregistering firmware_attributes_class devices may cause issues if there is more than one device under this class. See details in the commit message.

This patchset fixes this problem for all users.

---
Kurt Borja (3):
platform/x86: hp-bioscfg: Fix class device unregistration platform/x86: think-lmi: Fix class device unregistration platform/x86: dell-wmi-sysman: Fix class device unregistration

 drivers/platform/x86/dell/dell-wmi-sysman/sysman.c | 4 ++--
 drivers/platform/x86/hp/hp-bioscfg/bioscfg.c       | 4 ++--
 drivers/platform/x86/lenovo/think-lmi.c            | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

---
base-commit: 73f0f2b52c5ea67b3140b23f58d8079d158839c8
change-id: 20250625-dest-fix-b9de524340b2

Signature · 1 line
 ~ Kurt
author
#1 lore raw

PATCH 1/3 platform/x86: hp-bioscfg: Fix class device unregistration

Devices under the firmware_attributes_class do not have unique a dev_t. Therefore, device_unregister() should be used instead of device_destroy(), since the latter may match any device with a given dev_t.

Fixes a34fc329b189 ("platform/x86: hp-bioscfg: bioscfg")
---
 drivers/platform/x86/hp/hp-bioscfg/bioscfg.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/platform/x86/hp/hp-bioscfg/bioscfg.c +2 -2
index 13237890fc92002e7e730b1c235ddf068a6737cd..5bfa7159f5bcd57385a20fe9ac646597b320a378 100644
@@ -1034,7 +1034,7 @@ static int __init hp_init(void)
 	release_attributes_data();
 
 err_destroy_classdev:
-	device_destroy(&firmware_attributes_class, MKDEV(0, 0));
+	device_unregister(bioscfg_drv.class_dev);
 
 err_unregister_class:
 	hp_exit_attr_set_interface();
@@ -1045,7 +1045,7 @@ static int __init hp_init(void)
 static void __exit hp_exit(void)
 {
 	release_attributes_data();
-	device_destroy(&firmware_attributes_class, MKDEV(0, 0));
+	device_unregister(bioscfg_drv.class_dev);
 
 	hp_exit_attr_set_interface();
 }
Signature · 1 line
2.50.0
author
#2 lore raw

PATCH 2/3 platform/x86: think-lmi: Fix class device unregistration

In reply to Kurt Borja

Devices under the firmware_attributes_class do not have unique a dev_t. Therefore, device_unregister() should be used instead of device_destroy(), since the latter may match any device with a given dev_t.

Fixes a40cd7ef22fb ("platform/x86: think-lmi: Add WMI interface support on Lenovo platforms")
---
 drivers/platform/x86/lenovo/think-lmi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/platform/x86/lenovo/think-lmi.c +2 -2
index 34a47269e3d34d2eda6b71af73892656cd2bf67d..085d6fb8ff6a61009217dc2a397f73116bceeb61 100644
@@ -1556,7 +1556,7 @@ static int tlmi_sysfs_init(void)
 fail_create_attr:
 	tlmi_release_attr();
 fail_device_created:
-	device_destroy(&firmware_attributes_class, MKDEV(0, 0));
+	device_unregister(tlmi_priv.class_dev);
 fail_class_created:
 	return ret;
 }
@@ -1783,7 +1783,7 @@ static int tlmi_analyze(struct wmi_device *wdev)
 static void tlmi_remove(struct wmi_device *wdev)
 {
 	tlmi_release_attr();
-	device_destroy(&firmware_attributes_class, MKDEV(0, 0));
+	device_unregister(tlmi_priv.class_dev);
 }
 
 static int tlmi_probe(struct wmi_device *wdev, const void *context)
Signature · 1 line
2.50.0
author
#3 lore raw

PATCH 3/3 platform/x86: dell-wmi-sysman: Fix class device unregistration

In reply to Kurt Borja

Devices under the firmware_attributes_class do not have unique a dev_t. Therefore, device_unregister() should be used instead of device_destroy(), since the latter may match any device with a given dev_t.

Fixes e8a60aa7404b ("platform/x86: Introduce support for Systems Management Driver over WMI for Dell Systems")
---
 drivers/platform/x86/dell/dell-wmi-sysman/sysman.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/platform/x86/dell/dell-wmi-sysman/sysman.c +2 -2
index d00389b860e4ea0655c740c78bc3751f323b6370..e345c62fbb35529fb4903f8c11f0fd07d941f94d 100644
@@ -597,7 +597,7 @@ static int __init sysman_init(void)
 	release_attributes_data();
 
 err_destroy_classdev:
-	device_destroy(&firmware_attributes_class, MKDEV(0, 0));
+	device_unregister(wmi_priv.class_dev);
 
 err_exit_bios_attr_pass_interface:
 	exit_bios_attr_pass_interface();
@@ -611,7 +611,7 @@ static int __init sysman_init(void)
 static void __exit sysman_exit(void)
 {
 	release_attributes_data();
-	device_destroy(&firmware_attributes_class, MKDEV(0, 0));
+	device_unregister(wmi_priv.class_dev);
 	exit_bios_attr_set_interface();
 	exit_bios_attr_pass_interface();
 }
Signature · 1 line
2.50.0
maintainer
#4 lore raw
In reply to Kurt Borja
Quoted 8 lines · Kurt Borja

Using device_destroy() for unregistering firmware_attributes_class devices may cause issues if there is more than one device under this class. See details in the commit message.

This patchset fixes this problem for all users.

[...]

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/3] platform/x86: hp-bioscfg: Fix class device unregistration

      commit: 11cba4793b95df3bc192149a6eb044f69aa0b99e
[2/3] platform/x86: think-lmi: Fix class device unregistration
      commit: 5ff1fbb3059730700b4823f43999fc1315984632
[3/3] platform/x86: dell-wmi-sysman: Fix class device unregistration
      commit: 314e5ad4782d08858b3abc325c0487bd2abc23a1

--
i.