hc
2023-11-06 9df731a176aab8e03b984b681b1bea01ccff6644
u-boot/common/image-android.c
....@@ -6,14 +6,16 @@
66
77 #include <common.h>
88 #include <image.h>
9
-#include <android_image.h>
9
+#include <android_ab.h>
1010 #include <android_bootloader.h>
11
+#include <android_image.h>
1112 #include <malloc.h>
1213 #include <mapmem.h>
1314 #include <errno.h>
1415 #include <boot_rkimg.h>
1516 #include <crypto.h>
1617 #include <sysmem.h>
18
+#include <mp_boot.h>
1719 #include <u-boot/sha1.h>
1820 #ifdef CONFIG_RKIMG_BOOTLOADER
1921 #include <asm/arch/resource_img.h>
....@@ -28,8 +30,8 @@
2830 DECLARE_GLOBAL_DATA_PTR;
2931
3032 #define ANDROID_IMAGE_DEFAULT_KERNEL_ADDR 0x10008000
31
-#define ANDROID_Q_VER 10
3233 #define ANDROID_PARTITION_VENDOR_BOOT "vendor_boot"
34
+#define ANDROID_PARTITION_INIT_BOOT "init_boot"
3335
3436 #define BLK_CNT(_num_bytes, _block_size) \
3537 ((_num_bytes + _block_size - 1) / _block_size)
....@@ -37,27 +39,110 @@
3739 static char andr_tmp_str[ANDR_BOOT_ARGS_SIZE + 1];
3840 static u32 android_kernel_comp_type = IH_COMP_NONE;
3941
40
-u32 android_image_major_version(void)
42
+static int android_version_init(void)
4143 {
42
- /* MSB 7-bits */
43
- return gd->bd->bi_andr_version >> 25;
44
+ struct andr_img_hdr *hdr = NULL;
45
+ struct blk_desc *desc;
46
+ const char *part_name = PART_BOOT;
47
+ disk_partition_t part;
48
+ int os_version;
49
+
50
+ desc = rockchip_get_bootdev();
51
+ if (!desc) {
52
+ printf("No bootdev\n");
53
+ return -1;
54
+ }
55
+
56
+#ifdef CONFIG_ANDROID_AB
57
+ part_name = ab_can_find_recovery_part() ? PART_RECOVERY : PART_BOOT;
58
+#endif
59
+ if (part_get_info_by_name(desc, part_name, &part) < 0)
60
+ return -1;
61
+
62
+ hdr = populate_andr_img_hdr(desc, &part);
63
+ if (!hdr)
64
+ return -1;
65
+
66
+ os_version = hdr->os_version;
67
+ if (os_version)
68
+ printf("Android %u.%u, Build %u.%u, v%d\n",
69
+ (os_version >> 25) & 0x7f, (os_version >> 18) & 0x7F,
70
+ ((os_version >> 4) & 0x7f) + 2000, os_version & 0x0F,
71
+ hdr->header_version);
72
+ free(hdr);
73
+
74
+ return (os_version >> 25) & 0x7f;
4475 }
4576
4677 u32 android_bcb_msg_sector_offset(void)
4778 {
79
+ static int android_version = -1; /* static */
80
+
4881 /*
49
- * Rockchip platforms defines BCB message at the 16KB offset of
50
- * misc partition while the Google defines it at 0x00 offset.
82
+ * get android os version:
5183 *
52
- * From Android-Q, the 0x00 offset is mandary on Google VTS, so that
53
- * this is a compatibility according to android image 'os_version'.
84
+ * There are two types of misc.img:
85
+ * Rockchip platforms defines BCB message at the 16KB offset of
86
+ * misc.img except for the Android version >= 10. Because Google
87
+ * defines it at 0x00 offset, and from Android-10 it becoms mandary
88
+ * on Google VTS.
89
+ *
90
+ * So we must get android 'os_version' to identify which type we
91
+ * are using, then we could able to use rockchip_get_boot_mode()
92
+ * which reads BCB from misc.img.
5493 */
5594 #ifdef CONFIG_RKIMG_BOOTLOADER
56
- return (android_image_major_version() >= ANDROID_Q_VER) ? 0x00 : 0x20;
95
+ if (android_version < 0)
96
+ android_version = android_version_init();
97
+
98
+ return (android_version >= 10) ? 0x00 : 0x20;
5799 #else
58100 return 0x00;
59101 #endif
60102 }
103
+
104
+#ifdef CONFIG_ROCKCHIP_RESOURCE_IMAGE
105
+int android_image_init_resource(struct blk_desc *desc,
106
+ disk_partition_t *out_part,
107
+ ulong *out_blk_offset)
108
+{
109
+ struct andr_img_hdr *hdr = NULL;
110
+ const char *part_name = ANDROID_PARTITION_BOOT;
111
+ disk_partition_t part;
112
+ ulong offset;
113
+ int ret = 0;
114
+
115
+ if (!desc)
116
+ return -ENODEV;
117
+
118
+#ifndef CONFIG_ANDROID_AB
119
+ if (rockchip_get_boot_mode() == BOOT_MODE_RECOVERY)
120
+ part_name = ANDROID_PARTITION_RECOVERY;
121
+#endif
122
+ if (part_get_info_by_name(desc, part_name, &part) < 0)
123
+ return -ENOENT;
124
+
125
+ hdr = populate_andr_img_hdr(desc, &part);
126
+ if (!hdr)
127
+ return -EINVAL;
128
+
129
+ if (hdr->header_version >= 2 && hdr->dtb_size)
130
+ env_update("bootargs", "androidboot.dtb_idx=0");
131
+
132
+ if (hdr->header_version <= 2) {
133
+ offset = hdr->page_size +
134
+ ALIGN(hdr->kernel_size, hdr->page_size) +
135
+ ALIGN(hdr->ramdisk_size, hdr->page_size);
136
+ *out_part = part;
137
+ *out_blk_offset = DIV_ROUND_UP(offset, desc->blksz);
138
+ } else {
139
+ ret = -EINVAL;
140
+ }
141
+ free(hdr);
142
+
143
+ return ret;
144
+}
145
+#endif
61146
62147 static ulong android_image_get_kernel_addr(const struct andr_img_hdr *hdr)
63148 {
....@@ -323,7 +408,7 @@
323408
324409 typedef enum {
325410 IMG_KERNEL,
326
- IMG_RAMDISK,
411
+ IMG_RAMDISK, /* within boot.img or init_boot.img(Android-13 or later) */
327412 IMG_SECOND,
328413 IMG_RECOVERY_DTBO,
329414 IMG_RK_DTB, /* within resource.img in second position */
....@@ -343,7 +428,9 @@
343428 {
344429 struct blk_desc *desc = rockchip_get_bootdev();
345430 disk_partition_t part_vendor_boot;
431
+ disk_partition_t part_init_boot;
346432 __maybe_unused u32 typesz;
433
+ u32 andr_version = (hdr->os_version >> 25) & 0x7f;
347434 ulong pgsz = hdr->page_size;
348435 ulong blksz = desc->blksz;
349436 ulong blkcnt, blkoff;
....@@ -352,6 +439,7 @@
352439 ulong extra = 0;
353440 ulong length;
354441 void *buffer;
442
+ void *tmp = NULL;
355443 int ret = 0;
356444
357445 switch (img) {
....@@ -366,17 +454,20 @@
366454 return -ENOMEM;
367455 break;
368456 case IMG_VENDOR_RAMDISK:
369
- if (part_get_info_by_name(desc,
370
- ANDROID_PARTITION_VENDOR_BOOT,
371
- &part_vendor_boot) < 0) {
372
- printf("No vendor boot partition\n");
373
- return -ENOENT;
457
+ if (hdr->vendor_boot_buf) {
458
+ ram_base = hdr->vendor_boot_buf;
459
+ } else {
460
+ if (part_get_info_by_name(desc,
461
+ ANDROID_PARTITION_VENDOR_BOOT,
462
+ &part_vendor_boot) < 0) {
463
+ printf("No vendor boot partition\n");
464
+ return -ENOENT;
465
+ }
466
+ ram_base = 0;
374467 }
375
- /* Always load vendor boot from storage: avb full load boot/recovery */
468
+
376469 blkstart = part_vendor_boot.start;
377470 pgsz = hdr->vendor_page_size;
378
- ram_base = 0;
379
-
380471 bsoffs = ALIGN(VENDOR_BOOT_HDRv3_SIZE, pgsz);
381472 length = hdr->vendor_ramdisk_size;
382473 buffer = (void *)env_get_ulong("ramdisk_addr_r", 16, 0);
....@@ -400,7 +491,25 @@
400491 return -ENOMEM;
401492 break;
402493 case IMG_RAMDISK:
403
- bsoffs = pgsz + ALIGN(hdr->kernel_size, pgsz);
494
+ /* get ramdisk from init_boot.img ? */
495
+ if (hdr->header_version >= 4 && andr_version >= 13) {
496
+ if (hdr->init_boot_buf) {
497
+ ram_base = hdr->init_boot_buf;
498
+ } else {
499
+ if (part_get_info_by_name(desc,
500
+ ANDROID_PARTITION_INIT_BOOT, &part_init_boot) < 0) {
501
+ printf("No init boot partition\n");
502
+ return -ENOENT;
503
+ }
504
+ blkstart = part_init_boot.start;
505
+ ram_base = 0;
506
+ }
507
+ bsoffs = pgsz;
508
+ } else {
509
+ /* get ramdisk from generic boot.img */
510
+ bsoffs = pgsz + ALIGN(hdr->kernel_size, pgsz);
511
+ }
512
+
404513 length = hdr->ramdisk_size;
405514 buffer = (void *)env_get_ulong("ramdisk_addr_r", 16, 0);
406515 blkcnt = DIV_ROUND_UP(hdr->ramdisk_size, blksz);
....@@ -412,15 +521,20 @@
412521 * | ramdisk |
413522 * |----------------|
414523 *
415
- * ramdisk_addr_r v3:
524
+ * ramdisk_addr_r v3 (Android-11 and later):
416525 * |----------------|---------|
417526 * | vendor-ramdisk | ramdisk |
418527 * |----------------|---------|
419528 *
420
- * ramdisk_addr_r v4:
529
+ * ramdisk_addr_r v4 (Android-12 and later):
421530 * |----------------|---------|------------|------------|
422531 * | vendor-ramdisk | ramdisk | bootconfig | bootparams |
423532 * |----------------|---------|------------|------------|
533
+ *
534
+ * ramdisk_addr_r v4 + init_boot(Android-13 and later):
535
+ * |----------------|----------------|------------|------------|
536
+ * | vendor-ramdisk | (init_)ramdisk | bootconfig | bootparams |
537
+ * |----------------|----------------|------------|------------|
424538 */
425539 if (hdr->header_version >= 3) {
426540 buffer += hdr->vendor_ramdisk_size;
....@@ -439,17 +553,20 @@
439553 case IMG_BOOTCONFIG:
440554 if (hdr->header_version < 4)
441555 return 0;
442
- if (part_get_info_by_name(desc,
443
- ANDROID_PARTITION_VENDOR_BOOT,
444
- &part_vendor_boot) < 0) {
445
- printf("No vendor boot partition\n");
446
- return -ENOENT;
447
- }
448556
557
+ if (hdr->vendor_boot_buf) {
558
+ ram_base = hdr->vendor_boot_buf;
559
+ } else {
560
+ if (part_get_info_by_name(desc,
561
+ ANDROID_PARTITION_VENDOR_BOOT,
562
+ &part_vendor_boot) < 0) {
563
+ printf("No vendor boot partition\n");
564
+ return -ENOENT;
565
+ }
566
+ ram_base = 0;
567
+ }
449568 blkstart = part_vendor_boot.start;
450569 pgsz = hdr->vendor_page_size;
451
- ram_base = 0;
452
-
453570 bsoffs = ALIGN(VENDOR_BOOT_HDRv4_SIZE, pgsz) +
454571 ALIGN(hdr->vendor_ramdisk_size, pgsz) +
455572 ALIGN(hdr->dtb_size, pgsz) +
....@@ -471,7 +588,7 @@
471588 ALIGN(hdr->ramdisk_size, pgsz);
472589 length = hdr->second_size;
473590 blkcnt = DIV_ROUND_UP(hdr->second_size, blksz);
474
- buffer = malloc(blkcnt * blksz);
591
+ buffer = tmp = malloc(blkcnt * blksz);
475592 typesz = sizeof(hdr->second_size);
476593 break;
477594 case IMG_RECOVERY_DTBO:
....@@ -481,7 +598,7 @@
481598 ALIGN(hdr->second_size, pgsz);
482599 length = hdr->recovery_dtbo_size;
483600 blkcnt = DIV_ROUND_UP(hdr->recovery_dtbo_size, blksz);
484
- buffer = malloc(blkcnt * blksz);
601
+ buffer = tmp = malloc(blkcnt * blksz);
485602 typesz = sizeof(hdr->recovery_dtbo_size);
486603 break;
487604 case IMG_DTB:
....@@ -492,7 +609,7 @@
492609 ALIGN(hdr->recovery_dtbo_size, pgsz);
493610 length = hdr->dtb_size;
494611 blkcnt = DIV_ROUND_UP(hdr->dtb_size, blksz);
495
- buffer = malloc(blkcnt * blksz);
612
+ buffer = tmp = malloc(blkcnt * blksz);
496613 typesz = sizeof(hdr->dtb_size);
497614 break;
498615 case IMG_RK_DTB:
....@@ -540,14 +657,19 @@
540657 if (hdr->header_version < 3) {
541658 #ifdef CONFIG_ANDROID_BOOT_IMAGE_HASH
542659 #ifdef CONFIG_DM_CRYPTO
543
- crypto_sha_update(crypto, (u32 *)buffer, length);
544
- crypto_sha_update(crypto, (u32 *)&length, typesz);
660
+ if (crypto) {
661
+ crypto_sha_update(crypto, (u32 *)buffer, length);
662
+ crypto_sha_update(crypto, (u32 *)&length, typesz);
663
+ }
545664 #else
546665 sha1_update(&sha1_ctx, (void *)buffer, length);
547666 sha1_update(&sha1_ctx, (void *)&length, typesz);
548667 #endif
549668 #endif
550669 }
670
+
671
+ if (tmp)
672
+ free(tmp);
551673
552674 return 0;
553675 }
....@@ -605,7 +727,12 @@
605727 return -1;
606728
607729 #ifdef CONFIG_ANDROID_BOOT_IMAGE_HASH
608
- if (hdr->header_version < 3) {
730
+ int verify = 1;
731
+
732
+#ifdef CONFIG_MP_BOOT
733
+ verify = mpb_post(3);
734
+#endif
735
+ if (hdr->header_version < 3 && verify) {
609736 struct udevice *dev = NULL;
610737 uchar hash[20];
611738 #ifdef CONFIG_DM_CRYPTO
....@@ -936,6 +1063,7 @@
9361063 const disk_partition_t *boot_img)
9371064 {
9381065 struct boot_img_hdr_v34 *boot_hdr;
1066
+ disk_partition_t part;
9391067 long blk_cnt, blks_read;
9401068
9411069 blk_cnt = BLK_CNT(sizeof(struct boot_img_hdr_v34), dev_desc->blksz);
....@@ -960,6 +1088,13 @@
9601088 printf("boot header %d, is not >= v3.\n",
9611089 boot_hdr->header_version);
9621090 return NULL;
1091
+ }
1092
+
1093
+ /* Start from android-13 GKI, it doesn't assign 'os_version' */
1094
+ if (boot_hdr->header_version >= 4 && boot_hdr->os_version == 0) {
1095
+ if (part_get_info_by_name(dev_desc,
1096
+ ANDROID_PARTITION_INIT_BOOT, &part) > 0)
1097
+ boot_hdr->os_version = 13 << 25;
9631098 }
9641099
9651100 return boot_hdr;
....@@ -1003,19 +1138,26 @@
10031138 return vboot_hdr;
10041139 }
10051140
1006
-static int populate_boot_info(const struct boot_img_hdr_v34 *boot_hdr,
1007
- const struct vendor_boot_img_hdr_v34 *vendor_hdr,
1008
- struct andr_img_hdr *hdr)
1141
+int populate_boot_info(const struct boot_img_hdr_v34 *boot_hdr,
1142
+ const struct vendor_boot_img_hdr_v34 *vendor_boot_hdr,
1143
+ const struct boot_img_hdr_v34 *init_boot_hdr,
1144
+ struct andr_img_hdr *hdr, bool save_hdr)
10091145 {
10101146 memset(hdr->magic, 0, ANDR_BOOT_MAGIC_SIZE);
10111147 memcpy(hdr->magic, boot_hdr->magic, ANDR_BOOT_MAGIC_SIZE);
10121148
10131149 hdr->kernel_size = boot_hdr->kernel_size;
1014
- /* don't use vendor_hdr->kernel_addr, we prefer "hdr + hdr->page_size" */
1150
+ /* don't use vendor_boot_hdr->kernel_addr, we prefer "hdr + hdr->page_size" */
10151151 hdr->kernel_addr = ANDROID_IMAGE_DEFAULT_KERNEL_ADDR;
1016
- /* generic ramdisk: immediately following the vendor ramdisk */
1017
- hdr->boot_ramdisk_size = boot_hdr->ramdisk_size;
1018
- hdr->ramdisk_size = boot_hdr->ramdisk_size;
1152
+
1153
+ /*
1154
+ * generic ramdisk: immediately following the vendor ramdisk.
1155
+ * It can be from init_boot.img or boot.img.
1156
+ */
1157
+ if (init_boot_hdr)
1158
+ hdr->ramdisk_size = init_boot_hdr->ramdisk_size;
1159
+ else
1160
+ hdr->ramdisk_size = boot_hdr->ramdisk_size;
10191161
10201162 /* actually, useless */
10211163 hdr->ramdisk_addr = env_get_ulong("ramdisk_addr_r", 16, 0);
....@@ -1024,7 +1166,7 @@
10241166 hdr->second_size = 0;
10251167 hdr->second_addr = 0;
10261168
1027
- hdr->tags_addr = vendor_hdr->tags_addr;
1169
+ hdr->tags_addr = vendor_boot_hdr->tags_addr;
10281170
10291171 /* fixed in v3 */
10301172 hdr->page_size = 4096;
....@@ -1032,7 +1174,7 @@
10321174 hdr->os_version = boot_hdr->os_version;
10331175
10341176 memset(hdr->name, 0, ANDR_BOOT_NAME_SIZE);
1035
- strncpy(hdr->name, (const char *)vendor_hdr->name, ANDR_BOOT_NAME_SIZE);
1177
+ strncpy(hdr->name, (const char *)vendor_boot_hdr->name, ANDR_BOOT_NAME_SIZE);
10361178
10371179 /* removed in v3 */
10381180 memset(hdr->cmdline, 0, ANDR_BOOT_ARGS_SIZE);
....@@ -1042,14 +1184,14 @@
10421184 hdr->recovery_dtbo_offset = 0;
10431185
10441186 hdr->header_size = boot_hdr->header_size;
1045
- hdr->dtb_size = vendor_hdr->dtb_size;
1046
- hdr->dtb_addr = vendor_hdr->dtb_addr;
1187
+ hdr->dtb_size = vendor_boot_hdr->dtb_size;
1188
+ hdr->dtb_addr = vendor_boot_hdr->dtb_addr;
10471189
10481190 /* boot_img_hdr_v34 fields */
1049
- hdr->vendor_ramdisk_size = vendor_hdr->vendor_ramdisk_size;
1050
- hdr->vendor_page_size = vendor_hdr->page_size;
1051
- hdr->vendor_header_version = vendor_hdr->header_version;
1052
- hdr->vendor_header_size = vendor_hdr->header_size;
1191
+ hdr->vendor_ramdisk_size = vendor_boot_hdr->vendor_ramdisk_size;
1192
+ hdr->vendor_page_size = vendor_boot_hdr->page_size;
1193
+ hdr->vendor_header_version = vendor_boot_hdr->header_version;
1194
+ hdr->vendor_header_size = vendor_boot_hdr->header_size;
10531195
10541196 hdr->total_cmdline = calloc(1, TOTAL_BOOT_ARGS_SIZE);
10551197 if (!hdr->total_cmdline)
....@@ -1057,30 +1199,33 @@
10571199 strncpy(hdr->total_cmdline, (const char *)boot_hdr->cmdline,
10581200 sizeof(boot_hdr->cmdline));
10591201 strncat(hdr->total_cmdline, " ", 1);
1060
- strncat(hdr->total_cmdline, (const char *)vendor_hdr->cmdline,
1061
- sizeof(vendor_hdr->cmdline));
1202
+ strncat(hdr->total_cmdline, (const char *)vendor_boot_hdr->cmdline,
1203
+ sizeof(vendor_boot_hdr->cmdline));
10621204
10631205 /* new for header v4 */
1064
- if (vendor_hdr->header_version > 3) {
1206
+ if (vendor_boot_hdr->header_version >= 4) {
10651207 hdr->vendor_ramdisk_table_size =
1066
- vendor_hdr->vendor_ramdisk_table_size;
1208
+ vendor_boot_hdr->vendor_ramdisk_table_size;
10671209 hdr->vendor_ramdisk_table_entry_num =
1068
- vendor_hdr->vendor_ramdisk_table_entry_num;
1210
+ vendor_boot_hdr->vendor_ramdisk_table_entry_num;
10691211 hdr->vendor_ramdisk_table_entry_size =
1070
- vendor_hdr->vendor_ramdisk_table_entry_size;
1212
+ vendor_boot_hdr->vendor_ramdisk_table_entry_size;
10711213 /*
10721214 * If we place additional "androidboot.xxx" parameters after
10731215 * bootconfig, this field value should be increased,
10741216 * but not over than ANDROID_ADDITION_BOOTCONFIG_PARAMS_MAX_SIZE.
10751217 */
10761218 hdr->vendor_bootconfig_size =
1077
- vendor_hdr->vendor_bootconfig_size;
1219
+ vendor_boot_hdr->vendor_bootconfig_size;
10781220 } else {
10791221 hdr->vendor_ramdisk_table_size = 0;
10801222 hdr->vendor_ramdisk_table_entry_num = 0;
10811223 hdr->vendor_ramdisk_table_entry_size = 0;
10821224 hdr->vendor_bootconfig_size = 0;
10831225 }
1226
+
1227
+ hdr->init_boot_buf = save_hdr ? (void *)init_boot_hdr : 0;
1228
+ hdr->vendor_boot_buf = save_hdr ? (void *)vendor_boot_hdr : 0;
10841229
10851230 if (hdr->page_size < sizeof(*hdr)) {
10861231 printf("android hdr is over size\n");
....@@ -1110,10 +1255,13 @@
11101255 disk_partition_t *part_boot)
11111256 {
11121257 disk_partition_t part_vendor_boot;
1113
- struct vendor_boot_img_hdr_v34 *vboot_hdr;
1114
- struct boot_img_hdr_v34 *boot_hdr;
1115
- struct andr_img_hdr *andr_hdr;
1258
+ disk_partition_t part_init_boot;
1259
+ struct vendor_boot_img_hdr_v34 *vboot_hdr = NULL;
1260
+ struct boot_img_hdr_v34 *iboot_hdr = NULL;
1261
+ struct boot_img_hdr_v34 *boot_hdr = NULL;
1262
+ struct andr_img_hdr *andr_hdr = NULL;
11161263 int header_version;
1264
+ int andr_version;
11171265
11181266 if (!dev_desc || !part_boot)
11191267 return NULL;
....@@ -1134,6 +1282,7 @@
11341282
11351283 header_version = andr_hdr->header_version;
11361284 free(andr_hdr);
1285
+ andr_hdr = NULL;
11371286
11381287 if (header_version < 3) {
11391288 return extract_boot_image_v012_header(dev_desc, part_boot);
....@@ -1150,6 +1299,23 @@
11501299 if (!boot_hdr || !vboot_hdr)
11511300 goto image_load_exit;
11521301
1302
+ andr_version = (boot_hdr->os_version >> 25) & 0x7f;
1303
+ if (header_version >= 4 && andr_version >= 13) {
1304
+ if (part_get_info_by_name(dev_desc,
1305
+ ANDROID_PARTITION_INIT_BOOT,
1306
+ &part_init_boot) < 0) {
1307
+ printf("No init boot partition\n");
1308
+ return NULL;
1309
+ }
1310
+ iboot_hdr = extract_boot_image_v34_header(dev_desc, &part_init_boot);
1311
+ if (!iboot_hdr)
1312
+ goto image_load_exit;
1313
+ if (!iboot_hdr->ramdisk_size) {
1314
+ printf("No ramdisk in init boot partition\n");
1315
+ goto image_load_exit;
1316
+ }
1317
+ }
1318
+
11531319 andr_hdr = (struct andr_img_hdr *)
11541320 malloc(sizeof(struct andr_img_hdr));
11551321 if (!andr_hdr) {
....@@ -1157,21 +1323,21 @@
11571323 goto image_load_exit;
11581324 }
11591325
1160
- if (populate_boot_info(boot_hdr, vboot_hdr, andr_hdr)) {
1326
+ if (populate_boot_info(boot_hdr, vboot_hdr,
1327
+ iboot_hdr, andr_hdr, false)) {
11611328 printf("populate boot info failed\n");
11621329 goto image_load_exit;
11631330 }
11641331
1165
- free(boot_hdr);
1166
- free(vboot_hdr);
1332
+image_load_exit:
1333
+ if (boot_hdr)
1334
+ free(boot_hdr);
1335
+ if (iboot_hdr)
1336
+ free(iboot_hdr);
1337
+ if (vboot_hdr)
1338
+ free(vboot_hdr);
11671339
11681340 return andr_hdr;
1169
-
1170
-image_load_exit:
1171
- free(boot_hdr);
1172
- free(vboot_hdr);
1173
-
1174
- return NULL;
11751341 }
11761342
11771343 return NULL;