Skip to content

Commit 703c13f

Browse files
jhovoldardbiesheuvel
authored andcommitted
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: 98086df ("efi: add missed destroy_workqueue when efisubsys_init fails") Cc: [email protected] Cc: Li Heng <[email protected]> Signed-off-by: Johan Hovold <[email protected]> Signed-off-by: Ard Biesheuvel <[email protected]>
1 parent 88603b6 commit 703c13f

File tree

1 file changed

+6
-3
lines changed
  • drivers/firmware/efi

1 file changed

+6
-3
lines changed

drivers/firmware/efi/efi.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,8 @@ static int __init efisubsys_init(void)
394394
efi_kobj = kobject_create_and_add("efi", firmware_kobj);
395395
if (!efi_kobj) {
396396
pr_err("efi: Firmware registration failed.\n");
397-
destroy_workqueue(efi_rts_wq);
398-
return -ENOMEM;
397+
error = -ENOMEM;
398+
goto err_destroy_wq;
399399
}
400400

401401
if (efi_rt_services_supported(EFI_RT_SUPPORTED_GET_VARIABLE |
@@ -443,7 +443,10 @@ static int __init efisubsys_init(void)
443443
err_put:
444444
kobject_put(efi_kobj);
445445
efi_kobj = NULL;
446-
destroy_workqueue(efi_rts_wq);
446+
err_destroy_wq:
447+
if (efi_rts_wq)
448+
destroy_workqueue(efi_rts_wq);
449+
447450
return error;
448451
}
449452

0 commit comments

Comments
 (0)