Skip to contentSkip to conversation

efi: Don't destroy runtime workqueue on efisubsys_init() failure

PATCH New Ard Biesheuvel 1 participant 1 message Nov 20

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

PATCH 1/1 efi: Don't destroy runtime workqueue on efisubsys_init() failure

From: Ard Biesheuvel <[email protected]>

Commit 98086df8b70c ("efi: add missed destroy_workqueue when efisubsys_init fails") added a destroy_workqueue(efi_rts_wq) call to the error cleanup path of efisubsys_init() without clearing EFI_RUNTIME_SERVICES in efi.flags, leaving __efi_queue_work() passing a freed workqueue pointer to queue_work() on any subsequent runtime service call (for instance via the rtc-efi device registered right before efi_kobj is created).

Furthermore, since commit 13c6da02e767 ("efi: Allocate runtime workqueue before ACPI init"), efi_rts_wq is no longer allocated by efisubsys_init() at all, as efipostcore_init() allocates it earlier for consumers such as ACPI PRM that do not depend on /sys/firmware/efi.

Drop the bogus destroy_workqueue() cleanup from efisubsys_init().

Fixes 98086df8b70c ("efi: add missed destroy_workqueue when efisubsys_init fails")
Fixes 13c6da02e767 ("efi: Allocate runtime workqueue before ACPI init")
---
 drivers/firmware/efi/efi.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/firmware/efi/efi.c +1 -5
index 9bc22de0d67e..40b423f85e06 100644
@@ -466,8 +466,7 @@ static int __init efisubsys_init(void)
 	efi_kobj = kobject_create_and_add("efi", firmware_kobj);
 	if (!efi_kobj) {
 		pr_err("efi: Firmware registration failed.\n");
-		error = -ENOMEM;
-		goto err_destroy_wq;
+		return -ENOMEM;
 	}
 
 	if (IS_ENABLED(CONFIG_PREEMPT_RT) && efi.runtime_supported_mask) {
@@ -525,9 +524,6 @@ static int __init efisubsys_init(void)
 err_put:
 	kobject_put(efi_kobj);
 	efi_kobj = NULL;
-err_destroy_wq:
-	if (efi_rts_wq)
-		destroy_workqueue(efi_rts_wq);
 
 	return error;
 }
Signature · 1 line
2.56.1.750.gf70dc682cf-goog