[PATCH 094/112] efi: payload: protect against buggy EFI implementations

Ahmad Fatoum a.fatoum at pengutronix.de
Wed Jan 3 10:12:54 PST 2024


barebox' EFI loaded image handle should have a device path, but on the
off-case that it doesn't, we should just return an error code instead of
dereferencing a null pointer.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 efi/payload/init.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/efi/payload/init.c b/efi/payload/init.c
index 354120b11a86..b312866cb1f6 100644
--- a/efi/payload/init.c
+++ b/efi/payload/init.c
@@ -327,6 +327,9 @@ static int efi_postcore_init(void)
 	loaded_image_dp = device_path_from_handle(efi_loaded_image->device_handle);
 	pr_debug("loaded-image: %pD\n", loaded_image_dp);
 
+	if (!loaded_image_dp)
+		return -EINVAL;
+
 	uuid = device_path_to_partuuid(loaded_image_dp);
 	if (uuid) {
 		wchar_t *uuid16 = xstrdup_char_to_wchar(uuid);
-- 
2.39.2




More information about the barebox mailing list