[PATCH v2 095/113] efi: payload: protect against buggy EFI implementations

Ahmad Fatoum a.fatoum at pengutronix.de
Mon Mar 4 11:00:20 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 0f518d4954cb..5701d7ad6dcf 100644
--- a/efi/payload/init.c
+++ b/efi/payload/init.c
@@ -328,6 +328,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