diff mbox series

[U-Boot,1/1] efi_loader: LocateDevicePath() incorrectparameter check

Message ID 20190510173520.5605-1-xypron.glpk@gmx.de
State Accepted, archived
Delegated to: Heinrich Schuchardt
Headers show
Series [U-Boot,1/1] efi_loader: LocateDevicePath() incorrectparameter check | expand

Commit Message

Heinrich Schuchardt May 10, 2019, 5:35 p.m. UTC
A parameter check in LocateDevicePath() does not match the requirements of
the UEFI spec.

If device is NULL, only return EFI_INVALID_PARAMETER if a matching handle
is found.

Cf. UEFI SCT II specification (2017)3.3.7 LocateDevicePath(), 5.1.3.7.3

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
 lib/efi_loader/efi_boottime.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

--
2.20.1
diff mbox series

Patch

diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index b97d55cb45..a1fac60ee1 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -2261,7 +2261,7 @@  static efi_status_t EFIAPI efi_locate_device_path(

 	EFI_ENTRY("%pUl, %p, %p", protocol, device_path, device);

-	if (!protocol || !device_path || !*device_path || !device) {
+	if (!protocol || !device_path || !*device_path) {
 		ret = EFI_INVALID_PARAMETER;
 		goto out;
 	}
@@ -2294,6 +2294,10 @@  static efi_status_t EFIAPI efi_locate_device_path(
 		/* Check if dp is a subpath of device_path */
 		if (memcmp(*device_path, dp, len_dp))
 			continue;
+		if (!device) {
+			ret = EFI_INVALID_PARAMETER;
+			goto out;
+		}
 		*device = handles[i];
 		len_best = len_dp;
 	}