summaryrefslogtreecommitdiffstats
path: root/drivers/platform/x86/think-lmi.c
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2021-11-18 12:41:50 +0100
committerHans de Goede <hdegoede@redhat.com>2021-11-22 13:51:31 +0100
commitff448bbaacfb6f216ae101c1f16d8c5142c16fdf (patch)
tree8b1a5a8931b2a62cf0cf825a81e78df5969eddbf /drivers/platform/x86/think-lmi.c
parent01df1385ec4ec699ad6a63007e7f1081089e83a0 (diff)
downloadlinux-ff448bbaacfb6f216ae101c1f16d8c5142c16fdf.tar.gz
linux-ff448bbaacfb6f216ae101c1f16d8c5142c16fdf.tar.bz2
linux-ff448bbaacfb6f216ae101c1f16d8c5142c16fdf.zip
platform/x86: think-lmi: Simplify tlmi_analyze() error handling a bit
Creating the tlmi_pwd_setting structs can only fail with -ENOMEM, set ret to this once and simplify the error handling a bit. Tested-by: Mark Pearson <markpearson@lenovo.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Link: https://lore.kernel.org/r/20211118114150.271274-2-hdegoede@redhat.com
Diffstat (limited to 'drivers/platform/x86/think-lmi.c')
-rw-r--r--drivers/platform/x86/think-lmi.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/drivers/platform/x86/think-lmi.c b/drivers/platform/x86/think-lmi.c
index 6eba69334fa6..27ab8e4e5b83 100644
--- a/drivers/platform/x86/think-lmi.c
+++ b/drivers/platform/x86/think-lmi.c
@@ -1141,42 +1141,38 @@ static int tlmi_analyze(void)
if (ret)
goto fail_clear_attr;
+ /* All failures below boil down to kmalloc failures */
+ ret = -ENOMEM;
+
tlmi_priv.pwd_admin = tlmi_create_auth("pap", "bios-admin");
- if (!tlmi_priv.pwd_admin) {
- ret = -ENOMEM;
+ if (!tlmi_priv.pwd_admin)
goto fail_clear_attr;
- }
+
if (tlmi_priv.pwdcfg.core.password_state & TLMI_PAP_PWD)
tlmi_priv.pwd_admin->valid = true;
tlmi_priv.pwd_power = tlmi_create_auth("pop", "power-on");
- if (!tlmi_priv.pwd_power) {
- ret = -ENOMEM;
+ if (!tlmi_priv.pwd_power)
goto fail_clear_attr;
- }
+
if (tlmi_priv.pwdcfg.core.password_state & TLMI_POP_PWD)
tlmi_priv.pwd_power->valid = true;
if (tlmi_priv.opcode_support) {
tlmi_priv.pwd_system = tlmi_create_auth("sys", "system");
- if (!tlmi_priv.pwd_system) {
- ret = -ENOMEM;
+ if (!tlmi_priv.pwd_system)
goto fail_clear_attr;
- }
+
if (tlmi_priv.pwdcfg.core.password_state & TLMI_SYS_PWD)
tlmi_priv.pwd_system->valid = true;
tlmi_priv.pwd_hdd = tlmi_create_auth("hdd", "hdd");
- if (!tlmi_priv.pwd_hdd) {
- ret = -ENOMEM;
+ if (!tlmi_priv.pwd_hdd)
goto fail_clear_attr;
- }
tlmi_priv.pwd_nvme = tlmi_create_auth("nvm", "nvme");
- if (!tlmi_priv.pwd_nvme) {
- ret = -ENOMEM;
+ if (!tlmi_priv.pwd_nvme)
goto fail_clear_attr;
- }
if (tlmi_priv.pwdcfg.core.password_state & TLMI_HDD_PWD) {
/* Check if PWD is configured and set index to first drive found */