]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
platform/x86: think-lmi: Fix attribute name usage for non-compliant items
authorMark Pearson <mpearson-lenovo@squebb.ca>
Tue, 20 May 2025 00:50:18 +0000 (20:50 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 29 May 2025 09:14:07 +0000 (11:14 +0200)
[ Upstream commit 8508427a6e21c1ef01ae4c9f4e2675fc99deb949 ]

A few, quite rare, WMI attributes have names that are not compatible with
filenames, e.g. "Intel VT for Directed I/O (VT-d)".
For these cases the '/' gets replaced with '\' for display, but doesn't
get switched again when doing the WMI access.

Fix this by keeping the original attribute name and using that for sending
commands to the BIOS

Fixes: a40cd7ef22fb ("platform/x86: think-lmi: Add WMI interface support on Lenovo platforms")
Signed-off-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Link: https://lore.kernel.org/r/20250520005027.3840705-1-mpearson-lenovo@squebb.ca
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/platform/x86/think-lmi.c
drivers/platform/x86/think-lmi.h

index 323316ac6783aa343c4c6430040a4af648786880..e4b3b20d03f32e4984aabc94930c5ba349290e9c 100644 (file)
@@ -1065,8 +1065,8 @@ static ssize_t current_value_store(struct kobject *kobj,
                        ret = -EINVAL;
                        goto out;
                }
-               set_str = kasprintf(GFP_KERNEL, "%s,%s,%s", setting->display_name,
-                                       new_setting, tlmi_priv.pwd_admin->signature);
+               set_str = kasprintf(GFP_KERNEL, "%s,%s,%s", setting->name,
+                                   new_setting, tlmi_priv.pwd_admin->signature);
                if (!set_str) {
                        ret = -ENOMEM;
                        goto out;
@@ -1096,7 +1096,7 @@ static ssize_t current_value_store(struct kobject *kobj,
                                goto out;
                }
 
-               set_str = kasprintf(GFP_KERNEL, "%s,%s;", setting->display_name,
+               set_str = kasprintf(GFP_KERNEL, "%s,%s;", setting->name,
                                    new_setting);
                if (!set_str) {
                        ret = -ENOMEM;
@@ -1124,11 +1124,11 @@ static ssize_t current_value_store(struct kobject *kobj,
                }
 
                if (auth_str)
-                       set_str = kasprintf(GFP_KERNEL, "%s,%s,%s", setting->display_name,
-                                       new_setting, auth_str);
+                       set_str = kasprintf(GFP_KERNEL, "%s,%s,%s", setting->name,
+                                           new_setting, auth_str);
                else
-                       set_str = kasprintf(GFP_KERNEL, "%s,%s;", setting->display_name,
-                                       new_setting);
+                       set_str = kasprintf(GFP_KERNEL, "%s,%s;", setting->name,
+                                           new_setting);
                if (!set_str) {
                        ret = -ENOMEM;
                        goto out;
@@ -1633,9 +1633,6 @@ static int tlmi_analyze(void)
                        continue;
                }
 
-               /* It is not allowed to have '/' for file name. Convert it into '\'. */
-               strreplace(item, '/', '\\');
-
                /* Remove the value part */
                strreplace(item, ',', '\0');
 
@@ -1647,11 +1644,16 @@ static int tlmi_analyze(void)
                        goto fail_clear_attr;
                }
                setting->index = i;
+
+               strscpy(setting->name, item);
+               /* It is not allowed to have '/' for file name. Convert it into '\'. */
+               strreplace(item, '/', '\\');
                strscpy(setting->display_name, item);
+
                /* If BIOS selections supported, load those */
                if (tlmi_priv.can_get_bios_selections) {
-                       ret = tlmi_get_bios_selections(setting->display_name,
-                                       &setting->possible_values);
+                       ret = tlmi_get_bios_selections(setting->name,
+                                                      &setting->possible_values);
                        if (ret || !setting->possible_values)
                                pr_info("Error retrieving possible values for %d : %s\n",
                                                i, setting->display_name);
index f267d8b46957e6bdc75e534e5fd18c94e6379208..95a3d935edaaf2480885a18ed2960b316369cff2 100644 (file)
@@ -88,6 +88,7 @@ struct tlmi_pwd_setting {
 struct tlmi_attr_setting {
        struct kobject kobj;
        int index;
+       char name[TLMI_SETTINGS_MAXLEN];
        char display_name[TLMI_SETTINGS_MAXLEN];
        char *possible_values;
 };