[PATCH] boot: android: fix booting without a ramdisk

Simon Glass sjg at chromium.org
Sun Jul 28 21:36:07 CEST 2024


Hi Michael,

On Fri, 26 Jul 2024 at 17:00, Michael Walle <mwalle at kernel.org> wrote:
>
> android_image_get_ramdisk() will return an error if there is no ramdisk.
> Using the android image without a ramdisk worked until commit
> 1ce8e10f3b4b ("image: Fix up ANDROID_BOOT_IMAGE ramdisk code") because
> that return code wasn't checked. Now that it is checked, don't return an
> error in the (valid) case that there is no ramdisk in the image.
>
> With this, I'm able to boot a linux kernel using fastboot again:
>
>   fastboot --base 0x41000000 --header-version 2 --dtb /path/to/dtb \
>   --cmdline "root=/dev/mmcblk0p1 rootwait" boot path/to/Image
>
> Signed-off-by: Michael Walle <mwalle at kernel.org>
> ---
>  boot/image-android.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/boot/image-android.c b/boot/image-android.c
> index 09c7a44e058..0900579ee8c 100644
> --- a/boot/image-android.c
> +++ b/boot/image-android.c
> @@ -395,7 +395,7 @@ int android_image_get_ramdisk(const void *hdr, const void *vendor_boot_img,
>
>         if (!img_data.ramdisk_size) {
>                 *rd_data = *rd_len = 0;
> -               return -1;
> +               return 0;
>         }
>         if (img_data.header_version > 2) {
>                 ramdisk_ptr = img_data.ramdisk_addr;
> --
> 2.39.2
>

Rather than squashing the information here, you should return a value
that indicates there is no ramdisk. Normally in U-Boot this is
-ENOENT. Then the caller can check it. Also please update the function
docs in the header.

I see that -EINVAL is returned for some other error, so the caller
should be careful to just allow -ENOENT.

Regards,
Simon


More information about the U-Boot mailing list