Skip to contentSkip to conversation

efi_loader: LocateHandle should return EFI_NOT_FOUND if none found

PATCH New Rob Clark 3 participants 3 messages Aug 6, 2017 – Aug 31, 2017

lore
Share & tools
lore

Rob Clark

author
#0 lore raw

PATCH v2 1/1 efi_loader: LocateHandle should return EFI_NOT_FOUND if none found

Spotted this debugging OpenBSD's bootloader in qemu. (Wouldn't really fix anything, the problem was not having any disks, but we should probably return the correct error code.)

---
v2: early-return in the EFI_NOT_FOUND case, as suggested by Heinrich

 lib/efi_loader/efi_boottime.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
lib/efi_loader/efi_boottime.c +4 -1
index 5ff2d2d4b0..93ca05f3ef 100644
@@ -633,6 +633,10 @@ static efi_status_t EFIAPI efi_locate_handle(
 		return EFI_BUFFER_TOO_SMALL;
 	}
 
+	*buffer_size = size;
+	if (size == 0)
+		return EFI_NOT_FOUND;
+
 	/* Then fill the array */
 	list_for_each(lhandle, &efi_obj_list) {
 		struct efi_object *efiobj;
@@ -642,7 +646,6 @@ static efi_status_t EFIAPI efi_locate_handle(
 		}
 	}
 
-	*buffer_size = size;
 	return EFI_SUCCESS;
 }
 
Signature · 1 line
2.13.0
#1 lore raw

PATCH v2 1/1 efi_loader: LocateHandle should return EFI_NOT_FOUND if none found

Quoted 28 lines · Rob Clark

Spotted this debugging OpenBSD's bootloader in qemu. (Wouldn't really fix anything, the problem was not having any disks, but we should probably return the correct error code.)

---
v2: early-return in the EFI_NOT_FOUND case, as suggested by Heinrich

 lib/efi_loader/efi_boottime.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
lib/efi_loader/efi_boottime.c +4 -0
index 5ff2d2d4b0..93ca05f3ef 100644
@@ -633,6 +633,10 @@ static efi_status_t EFIAPI efi_locate_handle(
 		return EFI_BUFFER_TOO_SMALL;
 	}
 
+	*buffer_size = size;
+	if (size == 0)
+		return EFI_NOT_FOUND;
+
 	/* Then fill the array */
 	list_for_each(lhandle, &efi_obj_list) {
 		struct efi_object *efiobj;

lib/efi_loader/efi_boottime.c static efi_status_t EFIAPI efi_locate_handle( · line 651

Quoted 7 lines
lib/efi_loader/efi_boottime.c +0 -1
@@ -642,7 +646,6 @@ static efi_status_t EFIAPI efi_locate_handle(
 		}
 	}
 
-	*buffer_size = size;
 	return EFI_SUCCESS;
 }
 

@Alex:
This can be directly merged into efi-next. It has no further prerequisites.