boot: android: handle boot images with missing DTB
authorSam Day <me@samcday.com>
Thu, 23 Jan 2025 14:35:01 +0000 (14:35 +0000)
committerMattijs Korpershoek <mkorpershoek@baylibre.com>
Thu, 6 Feb 2025 08:09:09 +0000 (09:09 +0100)
607b07554e2 removed the check on the return status of the
android_image_get_dtb_img_addr call from android_image_get_dtb_by_index,
which results in null pointer accesses shortly after when trying to
check the header of a nonexistent DTB.

Fixes: 607b07554e2 ("android: boot: move to andr_image_data structure")
Signed-off-by: Sam Day <me@samcday.com>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Link: https://lore.kernel.org/r/20250123-android-handle-no-dtb-v1-1-1cb7373247da@samcday.com
Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
boot/image-android.c

index fa4e14c..1746b01 100644 (file)
@@ -696,7 +696,10 @@ bool android_image_get_dtb_by_index(ulong hdr_addr, ulong vendor_boot_img,
        ulong dtb_addr;         /* address of DTB blob with specified index  */
        u32 i;                  /* index iterator */
 
-       android_image_get_dtb_img_addr(hdr_addr, vendor_boot_img, &dtb_img_addr);
+       if (!android_image_get_dtb_img_addr(hdr_addr, vendor_boot_img,
+                                           &dtb_img_addr))
+               return false;
+
        /* Check if DTB area of boot image is in DTBO format */
        if (android_dt_check_header(dtb_img_addr)) {
                return android_dt_get_fdt_by_index(dtb_img_addr, index, addr,