[PATCH 009/112] efi: payload: image: return actual read_file() error

Ahmad Fatoum a.fatoum at pengutronix.de
Wed Jan 3 10:11:29 PST 2024


read_file returns NULL on error and sets errno, e.g. to ENOMEM if the
image to be booted exceeds memory available to barebox. Yet, errno was
ignored and EINVAL was returned as error code unconditionally. Fix this
to improve user experience.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 efi/payload/image.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/efi/payload/image.c b/efi/payload/image.c
index 8e39098ae81b..8d29bf9bb434 100644
--- a/efi/payload/image.c
+++ b/efi/payload/image.c
@@ -86,7 +86,7 @@ static int efi_load_image(const char *file, efi_loaded_image_t **loaded_image,
 
 	exe = read_file(file, &size);
 	if (!exe)
-		return -EINVAL;
+		return -errno;
 
 	efiret = BS->load_image(false, efi_parent_image, efi_device_path, exe, size,
 			&handle);
-- 
2.39.2




More information about the barebox mailing list