Skip to content

Commit 92f077f

Browse files
mrhpearsongregkh
authored andcommitted
platform/x86: think-lmi: Fix attribute name usage for non-compliant items
[ Upstream commit 8508427 ] 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: a40cd7e ("platform/x86: think-lmi: Add WMI interface support on Lenovo platforms") Signed-off-by: Mark Pearson <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Ilpo Järvinen <[email protected]> Signed-off-by: Ilpo Järvinen <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 5c54a55 commit 92f077f

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

drivers/platform/x86/think-lmi.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -995,8 +995,8 @@ static ssize_t current_value_store(struct kobject *kobj,
995995
ret = -EINVAL;
996996
goto out;
997997
}
998-
set_str = kasprintf(GFP_KERNEL, "%s,%s,%s", setting->display_name,
999-
new_setting, tlmi_priv.pwd_admin->signature);
998+
set_str = kasprintf(GFP_KERNEL, "%s,%s,%s", setting->name,
999+
new_setting, tlmi_priv.pwd_admin->signature);
10001000
if (!set_str) {
10011001
ret = -ENOMEM;
10021002
goto out;
@@ -1026,7 +1026,7 @@ static ssize_t current_value_store(struct kobject *kobj,
10261026
goto out;
10271027
}
10281028

1029-
set_str = kasprintf(GFP_KERNEL, "%s,%s;", setting->display_name,
1029+
set_str = kasprintf(GFP_KERNEL, "%s,%s;", setting->name,
10301030
new_setting);
10311031
if (!set_str) {
10321032
ret = -ENOMEM;
@@ -1054,11 +1054,11 @@ static ssize_t current_value_store(struct kobject *kobj,
10541054
}
10551055

10561056
if (auth_str)
1057-
set_str = kasprintf(GFP_KERNEL, "%s,%s,%s", setting->display_name,
1058-
new_setting, auth_str);
1057+
set_str = kasprintf(GFP_KERNEL, "%s,%s,%s", setting->name,
1058+
new_setting, auth_str);
10591059
else
1060-
set_str = kasprintf(GFP_KERNEL, "%s,%s;", setting->display_name,
1061-
new_setting);
1060+
set_str = kasprintf(GFP_KERNEL, "%s,%s;", setting->name,
1061+
new_setting);
10621062
if (!set_str) {
10631063
ret = -ENOMEM;
10641064
goto out;
@@ -1568,9 +1568,6 @@ static int tlmi_analyze(void)
15681568
continue;
15691569
}
15701570

1571-
/* It is not allowed to have '/' for file name. Convert it into '\'. */
1572-
strreplace(item, '/', '\\');
1573-
15741571
/* Remove the value part */
15751572
strreplace(item, ',', '\0');
15761573

@@ -1582,11 +1579,16 @@ static int tlmi_analyze(void)
15821579
goto fail_clear_attr;
15831580
}
15841581
setting->index = i;
1582+
1583+
strscpy(setting->name, item);
1584+
/* It is not allowed to have '/' for file name. Convert it into '\'. */
1585+
strreplace(item, '/', '\\');
15851586
strscpy(setting->display_name, item);
1587+
15861588
/* If BIOS selections supported, load those */
15871589
if (tlmi_priv.can_get_bios_selections) {
1588-
ret = tlmi_get_bios_selections(setting->display_name,
1589-
&setting->possible_values);
1590+
ret = tlmi_get_bios_selections(setting->name,
1591+
&setting->possible_values);
15901592
if (ret || !setting->possible_values)
15911593
pr_info("Error retrieving possible values for %d : %s\n",
15921594
i, setting->display_name);

drivers/platform/x86/think-lmi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ struct tlmi_pwd_setting {
8484
struct tlmi_attr_setting {
8585
struct kobject kobj;
8686
int index;
87+
char name[TLMI_SETTINGS_MAXLEN];
8788
char display_name[TLMI_SETTINGS_MAXLEN];
8889
char *possible_values;
8990
};

0 commit comments

Comments
 (0)