diff mbox series

[v2,3/3] efi_loader: return immediately in UCLASS_EFI_LOADER removal

Message ID 20240117094432.1049168-4-masahisa.kojima@linaro.org
State Superseded
Headers show
Series fix and refactoring of efi_disk.c | expand

Commit Message

Masahisa Kojima Jan. 17, 2024, 9:44 a.m. UTC
In case of UCLASS_EFI_LOADER, EFI handles are managed by
EFI application/driver, we must not delete EFI handles.

Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
---
 lib/efi_loader/efi_disk.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c
index 4897a7a7a8..cdf8a4560e 100644
--- a/lib/efi_loader/efi_disk.c
+++ b/lib/efi_loader/efi_disk.c
@@ -734,8 +734,14 @@  int efi_disk_remove(void *ctx, struct event *event)
 	switch (id) {
 	case UCLASS_BLK:
 		desc = dev_get_uclass_plat(dev);
-		if (desc && desc->uclass_id != UCLASS_EFI_LOADER)
-			diskobj = (struct efi_disk_obj *)handle;
+		if (desc && desc->uclass_id == UCLASS_EFI_LOADER)
+			/*
+			 * EFI application/driver manages the EFI handle,
+			 * no need to delete EFI handle.
+			 */
+			return 0;
+
+		diskobj = (struct efi_disk_obj *)handle;
 		break;
 	case UCLASS_PARTITION:
 		diskobj = (struct efi_disk_obj *)handle;
@@ -747,10 +753,8 @@  int efi_disk_remove(void *ctx, struct event *event)
 		return 0;
 	}
 
-	if (diskobj) {
-		dp = diskobj->dp;
-		volume = diskobj->volume;
-	}
+	dp = diskobj->dp;
+	volume = diskobj->volume;
 
 	ret = efi_delete_handle(handle);
 	/* Do not delete DM device if there are still EFI drivers attached. */