From: Simon Glass <sjg@chromium.org>
Date: Sun, 28 Aug 2022 18:32:46 +0000 (-0600)
Subject: image: Fix up ANDROID_BOOT_IMAGE ramdisk code
X-Git-Tag: v2025.01-rc5-pxa1908~1263^2~17^2~7
X-Git-Url: http://git.dujemihanovic.xyz/img/login.html?a=commitdiff_plain;h=1ce8e10f3b4b;p=u-boot.git

image: Fix up ANDROID_BOOT_IMAGE ramdisk code

Convert this to an if(), fix the cast from an address to a pointer and
make sure that any error is returned correctly.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

diff --git a/boot/image-board.c b/boot/image-board.c
index 4e4d1c157d..14b595977e 100644
--- a/boot/image-board.c
+++ b/boot/image-board.c
@@ -421,12 +421,19 @@ static int select_ramdisk(bootm_headers_t *images, const char *select, u8 arch,
 			images->fit_noffset_rd = rd_noffset;
 			break;
 #endif
-#ifdef CONFIG_ANDROID_BOOT_IMAGE
 		case IMAGE_FORMAT_ANDROID:
-			android_image_get_ramdisk((void *)images->os.start,
-						  rd_datap, rd_lenp);
-			break;
-#endif
+			if (IS_ENABLED(CONFIG_ANDROID_BOOT_IMAGE)) {
+				void *ptr = map_sysmem(images->os.start, 0);
+				int ret;
+
+				ret = android_image_get_ramdisk(ptr, rd_datap,
+								rd_lenp);
+				unmap_sysmem(ptr);
+				if (ret)
+					return ret;
+				break;
+			}
+			fallthrough;
 		default:
 			if (IS_ENABLED(CONFIG_SUPPORT_RAW_INITRD)) {
 				char *end = NULL;