summaryrefslogtreecommitdiff
path: root/boot
diff options
context:
space:
mode:
authorSafae Ouajih <souajih@baylibre.com>2023-02-06 00:50:05 +0100
committerPraneeth Bajjuri <praneeth@ti.com>2023-04-05 11:32:28 -0500
commit94dfef61a70808656bed741c133cdd7d5d3fb810 (patch)
treeef2b8897da04c20c7be4563c01b3b9f5931156be /boot
parent2df42cde901dd55641260e88f2397cf8f4a99f58 (diff)
android: boot: replace android_image_check_header
commit 734cb47d6de16d2e3b52a03bce5daab40e5bb29d upstream. With the new vendor boot image introduced in versions 3 and 4 of boot image header, the header check must be done for both boot image and vendor boot image. Thus, replace android_image_check_header() by is_android_boot_image_header() to only refer to boot image header check. Signed-off-by: Safae Ouajih <souajih@baylibre.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Tested-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Signed-off-by: Praneeth Bajjuri <praneeth@ti.com>
Diffstat (limited to 'boot')
-rw-r--r--boot/image-android.c17
-rw-r--r--boot/image-board.c2
2 files changed, 5 insertions, 14 deletions
diff --git a/boot/image-android.c b/boot/image-android.c
index b070974791..ac7cb479c1 100644
--- a/boot/image-android.c
+++ b/boot/image-android.c
@@ -122,18 +122,9 @@ int android_image_get_kernel(const struct andr_boot_img_hdr_v0 *hdr, int verify,
return 0;
}
-/**
- * android_image_check_header() - Check the magic of boot image
- *
- * This checks the header of Android boot image and verifies the
- * magic is "ANDROID!"
- *
- * @hdr: Pointer to boot image
- * Return: 0 if the magic is correct, non-zero if there is a magic mismatch
- */
-int android_image_check_header(const struct andr_boot_img_hdr_v0 *hdr)
+bool is_android_boot_image_header(const struct andr_boot_img_hdr_v0 *hdr)
{
- return memcmp(ANDR_BOOT_MAGIC, hdr->magic, ANDR_BOOT_MAGIC_SIZE);
+ return !memcmp(ANDR_BOOT_MAGIC, hdr, ANDR_BOOT_MAGIC_SIZE);
}
ulong android_image_get_end(const struct andr_boot_img_hdr_v0 *hdr)
@@ -240,7 +231,7 @@ bool android_image_get_dtbo(ulong hdr_addr, ulong *addr, u32 *size)
bool ret = true;
hdr = map_sysmem(hdr_addr, sizeof(*hdr));
- if (android_image_check_header(hdr)) {
+ if (!is_android_boot_image_header(hdr)) {
printf("Error: Boot Image header is incorrect\n");
ret = false;
goto exit;
@@ -289,7 +280,7 @@ static bool android_image_get_dtb_img_addr(ulong hdr_addr, ulong *addr)
bool ret = true;
hdr = map_sysmem(hdr_addr, sizeof(*hdr));
- if (android_image_check_header(hdr)) {
+ if (!is_android_boot_image_header(hdr)) {
printf("Error: Boot Image header is incorrect\n");
ret = false;
goto exit;
diff --git a/boot/image-board.c b/boot/image-board.c
index 25b60ec30b..b1dc756975 100644
--- a/boot/image-board.c
+++ b/boot/image-board.c
@@ -284,7 +284,7 @@ int genimg_get_format(const void *img_addr)
return IMAGE_FORMAT_FIT;
}
if (IS_ENABLED(CONFIG_ANDROID_BOOT_IMAGE) &&
- !android_image_check_header(img_addr))
+ is_android_boot_image_header(img_addr))
return IMAGE_FORMAT_ANDROID;
return IMAGE_FORMAT_INVALID;