Skip to contentSkip to conversation

efi: payload: handle NULL return from loadable_view for ramdisk

PATCH Applied Ahmad Fatoum 2 participants 2 messages May 7 – May 11

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 efi: payload: handle NULL return from loadable_view for ramdisk

loadable_view() can return NULL (distinct from ERR_PTR), which is not caught by IS_ERR().

efi_load_os() already handles this with the ?: ERR_PTR(-ENODATA) pattern, so apply the same to efi_load_ramdisk().

---
 efi/payload/bootm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
efi/payload/bootm.c +1 -1
index 30b6fe8977e0..2f9cc3cbf76b 100644
@@ -86,7 +86,7 @@ static int efi_load_ramdisk(struct image_data *data,
 	if (!data->initrd)
 		return 0;
 
-	initrd_mem = loadable_view(data->initrd, initrd_size);
+	initrd_mem = loadable_view(data->initrd, initrd_size) ?: ERR_PTR(-ENODATA);
 	if (IS_ERR(initrd_mem)) {
 		pr_err("Cannot open ramdisk image: %pe\n", initrd_mem);
 		return PTR_ERR(initrd_mem);
Signature · 1 line
2.47.3
Applied
#1 lore raw
Quoted 8 lines · Ahmad Fatoum

loadable_view() can return NULL (distinct from ERR_PTR), which is not caught by IS_ERR().

efi_load_os() already handles this with the ?: ERR_PTR(-ENODATA) pattern, so apply the same to efi_load_ramdisk().

[...]

Applied, thanks!

[1/1] efi: payload: handle NULL return from loadable_view for ramdisk
https://git.pengutronix.de/cgit/barebox/commit/?id=43a16ebe7493 (link may not be stable)

Best regards,

Signature · 1 line
Sascha Hauer <[email protected]>