Skip to contentSkip to conversation

platform/x86: think-lmi: Keep pending save state on failure

PATCH In review Thorsten Blum 2 participants 3 messages Aug 10 – Aug 11

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 platform/x86: think-lmi: Keep pending save state on failure

In save_settings_store(), the opcode and legacy password paths do not check if saving BIOS settings failed, but instead unconditionally clear save_required and set reboot_required, losing the pending save state.

Check the save result in those paths too.

Fixes 318d97849fc2 ("platform/x86: think-lmi: Add bulk save feature")
---
 drivers/platform/x86/lenovo/think-lmi.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/platform/x86/lenovo/think-lmi.c +4 -0
index e215e86e3db7..cc0a85d1b832 100644
@@ -1347,6 +1347,8 @@ static ssize_t save_settings_store(struct kobject *kobj, struct kobj_attribute *
 					goto out;
 			}
 			ret = tlmi_save_bios_settings("");
+			if (ret)
+				goto out;
 		} else { /* old non-opcode based authentication method (deprecated) */
 			if (tlmi_priv.pwd_admin->pwd_enabled && tlmi_priv.pwd_admin->password[0]) {
 				auth_str = kasprintf(GFP_KERNEL, "%s,%s,%s;",
@@ -1363,6 +1365,8 @@ static ssize_t save_settings_store(struct kobject *kobj, struct kobj_attribute *
 				ret = tlmi_save_bios_settings(auth_str);
 			else
 				ret = tlmi_save_bios_settings("");
+			if (ret)
+				goto out;
 		}
 		tlmi_priv.save_required = false;
 		tlmi_priv.reboot_required = true;
maintainer
#1 lore raw

Hi Thorsten,

Quoted 39 lines · Thorsten Blum

In save_settings_store(), the opcode and legacy password paths do not check if saving BIOS settings failed, but instead unconditionally clear save_required and set reboot_required, losing the pending save state.

Check the save result in those paths too.

Fixes 318d97849fc2 ("platform/x86: think-lmi: Add bulk save feature")
---
 drivers/platform/x86/lenovo/think-lmi.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/platform/x86/lenovo/think-lmi.c +2 -0
index e215e86e3db7..cc0a85d1b832 100644
@@ -1347,6 +1347,8 @@ static ssize_t save_settings_store(struct kobject 
 *kobj, struct kobj_attribute *
 					goto out;
 			}
 			ret = tlmi_save_bios_settings("");
+			if (ret)
+				goto out;
 		} else { /* old non-opcode based authentication method (deprecated) 
 */

if (tlmi_priv.pwd_admin->pwd_enabled &&
tlmi_priv.pwd_admin->password[0]) {

drivers/platform/x86/lenovo/think-lmi.c +2 -0
 				auth_str = kasprintf(GFP_KERNEL, "%s,%s,%s;",
@@ -1363,6 +1365,8 @@ static ssize_t save_settings_store(struct kobject 
 *kobj, struct kobj_attribute *
 				ret = tlmi_save_bios_settings(auth_str);
 			else
 				ret = tlmi_save_bios_settings("");
+			if (ret)
+				goto out;
 		}
 		tlmi_priv.save_required = false;
Quoted 1 line

tlmi_priv.reboot_required = true;

Curious - have you actually hit this condition?

My main thought is that if the save fails - chances are that something is pretty messed up and doing another save isn't going to fix it. Most likely you're going to have to reboot.

I'll see if I can get an answer from the FW team on expectations - but getting straight answers for error paths without a repro mechanism can be tricky.

Mark

#2 lore raw
Quoted 37 lines · Mark Pearson

Hi Thorsten,

Quoted 34 lines · Thorsten Blum

In save_settings_store(), the opcode and legacy password paths do not check if saving BIOS settings failed, but instead unconditionally clear save_required and set reboot_required, losing the pending save state.

Check the save result in those paths too.

Fixes 318d97849fc2 ("platform/x86: think-lmi: Add bulk save feature")
---
 drivers/platform/x86/lenovo/think-lmi.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/platform/x86/lenovo/think-lmi.c +2 -0
index e215e86e3db7..cc0a85d1b832 100644
@@ -1347,6 +1347,8 @@ static ssize_t save_settings_store(struct kobject 
 *kobj, struct kobj_attribute *
 					goto out;
 			}
 			ret = tlmi_save_bios_settings("");
+			if (ret)
+				goto out;
 		} else { /* old non-opcode based authentication method (deprecated) 
 */

if (tlmi_priv.pwd_admin->pwd_enabled &&
tlmi_priv.pwd_admin->password[0]) {

drivers/platform/x86/lenovo/think-lmi.c +0 -0
 				auth_str = kasprintf(GFP_KERNEL, "%s,%s,%s;",
@@ -1363,6 +1365,8 @@ static ssize_t save_settings_store(struct kobject 
 *kobj, struct kobj_attribute *
 				ret = tlmi_save_bios_settings(auth_str);
 			else
Quoted 8 lines
Quoted 6 lines
drivers/platform/x86/lenovo/think-lmi.c +2 -0
 				ret = tlmi_save_bios_settings("");
+			if (ret)
+				goto out;
 		}
 		tlmi_priv.save_required = false;

tlmi_priv.reboot_required = true;

Curious - have you actually hit this condition?

No, I was just reading the code and wondered why those return values aren't checked for errors.