Skip to content

Commit

Permalink
boot: android: handle boot images with missing DTB
Browse files Browse the repository at this point in the history
607b075 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: 607b075 ("android: boot: move to andr_image_data structure")
Signed-off-by: Sam Day <[email protected]>
Reviewed-by: Mattijs Korpershoek <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Mattijs Korpershoek <[email protected]>
  • Loading branch information
samcday authored and makohoek committed Feb 6, 2025
1 parent dcf1c62 commit aa817a2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion boot/image-android.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit aa817a2

Please sign in to comment.