summaryrefslogtreecommitdiffstats
path: root/drivers/platform
diff options
context:
space:
mode:
authorMario Limonciello <mario.limonciello@amd.com>2021-06-22 22:07:55 +0200
committerHans de Goede <hdegoede@redhat.com>2021-06-28 11:34:45 +0200
commit0fdf10e5fc964c315cf131a2eaab9cc531a9f40f (patch)
treed30cbbd7977b08037aa8fde717e4f099b579a371 /drivers/platform
parentplatform/x86: think-lmi: Fix issues with duplicate attributes (diff)
downloadlinux-0fdf10e5fc964c315cf131a2eaab9cc531a9f40f.tar.xz
linux-0fdf10e5fc964c315cf131a2eaab9cc531a9f40f.zip
platform/x86: think-lmi: Split current_value to reflect only the value
Currently attributes will show things like: `BootOrderLock,Disable` rather than just `Disable`. Of course this works, but the attribute is intended to be read by userspace tools and not require further processing. That is a userspace tool can display a drop down of `possible_values` and `current_value` is one of them from the list. This also aligns `think-lmi` with how `dell-wmi-sysman` works. Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Link: https://lore.kernel.org/r/20210622200755.12379-3-mario.limonciello@amd.com Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'drivers/platform')
-rw-r--r--drivers/platform/x86/think-lmi.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/platform/x86/think-lmi.c b/drivers/platform/x86/think-lmi.c
index bbfcaf23d420..4cab341a3538 100644
--- a/drivers/platform/x86/think-lmi.c
+++ b/drivers/platform/x86/think-lmi.c
@@ -492,14 +492,19 @@ static ssize_t display_name_show(struct kobject *kobj, struct kobj_attribute *at
static ssize_t current_value_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
{
struct tlmi_attr_setting *setting = to_tlmi_attr_setting(kobj);
- char *item;
+ char *item, *value;
int ret;
ret = tlmi_setting(setting->index, &item, LENOVO_BIOS_SETTING_GUID);
if (ret)
return ret;
- ret = sysfs_emit(buf, "%s\n", item);
+ /* validate and split from `item,value` -> `value` */
+ value = strpbrk(item, ",");
+ if (!value || value == item || !strlen(value + 1))
+ return -EINVAL;
+
+ ret = sysfs_emit(buf, "%s\n", value + 1);
kfree(item);
return ret;
}