[PATCH 05/12] bootm: android: fix PTR_ERR called after clearing error pointer

Ahmad Fatoum a.fatoum at pengutronix.de
Mon Feb 16 00:42:21 PST 2026


Both the kernel and initrd error paths set the pointer to NULL before
calling PTR_ERR(), which always yields 0 (apparent success) instead of
the actual error code from aimage_copy_component().

Swap the order so PTR_ERR() captures the error code before the pointer
is cleared.

Co-Authored-By: Claude Opus 4.6 <noreply at anthropic.com>
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 common/bootm-android-image.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/bootm-android-image.c b/common/bootm-android-image.c
index cb86123659ba..828400fef772 100644
--- a/common/bootm-android-image.c
+++ b/common/bootm-android-image.c
@@ -101,8 +101,8 @@ static int do_bootm_aimage(struct image_data *img_data)
 	if (hdr->kernel.size) {
 		kernel = aimage_copy_component(fd, ofs, hdr->kernel.size);
 		if (IS_ERR(kernel)) {
-			kernel = NULL;
 			ret = PTR_ERR(kernel);
+			kernel = NULL;
 			goto err_close;
 		}
 	}
@@ -112,8 +112,8 @@ static int do_bootm_aimage(struct image_data *img_data)
 	if (hdr->ramdisk.size) {
 		initrd = aimage_copy_component(fd, ofs, hdr->ramdisk.size);
 		if (IS_ERR(initrd)) {
-			initrd = NULL;
 			ret = PTR_ERR(initrd);
+			initrd = NULL;
 			goto err_close;
 		}
 	}
-- 
2.47.3




More information about the barebox mailing list