Commit 703c13fe authored by Johan Hovold's avatar Johan Hovold Committed by Ard Biesheuvel

efi: fix NULL-deref in init error path

In cases where runtime services are not supported or have been disabled,
the runtime services workqueue will never have been allocated.

Do not try to destroy the workqueue unconditionally in the unlikely
event that EFI initialisation fails to avoid dereferencing a NULL
pointer.

Fixes: 98086df8 ("efi: add missed destroy_workqueue when efisubsys_init fails")
Cc: stable@vger.kernel.org
Cc: Li Heng <liheng40@huawei.com>
Signed-off-by: default avatarJohan Hovold <johan+linaro@kernel.org>
Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
parent 88603b6d
...@@ -394,8 +394,8 @@ static int __init efisubsys_init(void) ...@@ -394,8 +394,8 @@ static int __init efisubsys_init(void)
efi_kobj = kobject_create_and_add("efi", firmware_kobj); efi_kobj = kobject_create_and_add("efi", firmware_kobj);
if (!efi_kobj) { if (!efi_kobj) {
pr_err("efi: Firmware registration failed.\n"); pr_err("efi: Firmware registration failed.\n");
destroy_workqueue(efi_rts_wq); error = -ENOMEM;
return -ENOMEM; goto err_destroy_wq;
} }
if (efi_rt_services_supported(EFI_RT_SUPPORTED_GET_VARIABLE | if (efi_rt_services_supported(EFI_RT_SUPPORTED_GET_VARIABLE |
...@@ -443,7 +443,10 @@ static int __init efisubsys_init(void) ...@@ -443,7 +443,10 @@ static int __init efisubsys_init(void)
err_put: err_put:
kobject_put(efi_kobj); kobject_put(efi_kobj);
efi_kobj = NULL; efi_kobj = NULL;
destroy_workqueue(efi_rts_wq); err_destroy_wq:
if (efi_rts_wq)
destroy_workqueue(efi_rts_wq);
return error; return error;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment