Skip to content

Commit 1bcad8e

Browse files
superm1jwrdegoede
authored andcommitted
platform/x86: think-lmi: Fix issues with duplicate attributes
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' ``` Duplicate and reserved values showing up appear to be a firmware bug, but they shouldn't make the driver explode. So catch them and skip them. Fixes: a40cd7e ("platform/x86: think-lmi: Add WMI interface support on Lenovo platforms") Signed-off-by: Mario Limonciello <[email protected]> Link: https://lore.kernel.org/r/[email protected] [[email protected]: Add missing kfree(tlmi_priv.setting[i])] Reviewed-by: Hans de Goede <[email protected]> Signed-off-by: Hans de Goede <[email protected]>
1 parent 71d69e8 commit 1bcad8e

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

drivers/platform/x86/think-lmi.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,17 @@ static int tlmi_sysfs_init(void)
691691
if (!tlmi_priv.setting[i])
692692
continue;
693693

694+
/* check for duplicate or reserved values */
695+
if (kset_find_obj(tlmi_priv.attribute_kset, tlmi_priv.setting[i]->display_name) ||
696+
!strcmp(tlmi_priv.setting[i]->display_name, "Reserved")) {
697+
pr_debug("duplicate or reserved attribute name found - %s\n",
698+
tlmi_priv.setting[i]->display_name);
699+
kfree(tlmi_priv.setting[i]->possible_values);
700+
kfree(tlmi_priv.setting[i]);
701+
tlmi_priv.setting[i] = NULL;
702+
continue;
703+
}
704+
694705
/* Build attribute */
695706
tlmi_priv.setting[i]->kobj.kset = tlmi_priv.attribute_kset;
696707
ret = kobject_init_and_add(&tlmi_priv.setting[i]->kobj, &tlmi_attr_setting_ktype,

0 commit comments

Comments
 (0)