All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] platform/x86: think-lmi: Fix issues with duplicate attributes
@ 2021-06-22 17:55 Mario Limonciello
  2021-06-22 19:55 ` [External] " Mark Pearson
  0 siblings, 1 reply; 4+ messages in thread
From: Mario Limonciello @ 2021-06-22 17:55 UTC (permalink / raw)
  To: Hans de Goede, Mark Gross, open list:X86 PLATFORM DRIVERS, markpearson
  Cc: Mario Limonciello

On an AMD based Lenovo T14, I find that the module doesn't work at
all, and instead has a traceback with messages like:

```
sysfs: cannot create duplicate filename '/devices/virtual/firmware-attributes/thinklmi/attributes/Reserved'
```

Check for duplicates before adding any attributes.

Fixes: a40cd7ef22fb ("platform/x86: think-lmi: Add WMI interface support on Lenovo platforms")
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
 drivers/platform/x86/think-lmi.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/platform/x86/think-lmi.c b/drivers/platform/x86/think-lmi.c
index d2644230b91f..b029d4a5bc3c 100644
--- a/drivers/platform/x86/think-lmi.c
+++ b/drivers/platform/x86/think-lmi.c
@@ -691,6 +691,13 @@ static int tlmi_sysfs_init(void)
 		if (!tlmi_priv.setting[i])
 			continue;
 
+		/* check for duplicate */
+		if (kset_find_obj(tlmi_priv.attribute_kset, tlmi_priv.setting[i]->display_name)) {
+			pr_debug("duplicate attribute name found - %s\n",
+				tlmi_priv.setting[i]->display_name);
+			continue;
+		}
+
 		/* Build attribute */
 		tlmi_priv.setting[i]->kobj.kset = tlmi_priv.attribute_kset;
 		ret = kobject_init_and_add(&tlmi_priv.setting[i]->kobj, &tlmi_attr_setting_ktype,
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-06-22 20:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-22 17:55 [PATCH] platform/x86: think-lmi: Fix issues with duplicate attributes Mario Limonciello
2021-06-22 19:55 ` [External] " Mark Pearson
2021-06-22 19:58   ` Limonciello, Mario
2021-06-22 20:04     ` Mark Pearson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.