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

Sascha Hauer s.hauer at pengutronix.de
Mon Feb 23 02:12:31 PST 2026


On Mon, Feb 16, 2026 at 09:42:21AM +0100, Ahmad Fatoum wrote:
> 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.

Squashed this and the next one into the original commit adding this
file.

Sascha

> 
> 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
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list