uboot-mediatek: fix determine the size of an uImage.FIT using 'imsz' or 'imszb'.
authorJianhui Zhao <zhaojh329@gmail.com>
Fri, 20 Oct 2023 03:59:34 +0000 (11:59 +0800)
committerDaniel Golle <daniel@makrotopia.org>
Tue, 31 Oct 2023 22:12:30 +0000 (22:12 +0000)
It must read the entire image for previous code of 'imsz' or 'imszb'.

Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
Suggested-by: Chuanhong Guo <gch981213@gmail.com>
package/boot/uboot-mediatek/patches/200-cmd-add-imsz-and-imszb.patch

index 574259fb395764ae32a384b341bb15e4b2d50e80..ae7623086e447517294e6da69af06cc00507375c 100644 (file)
@@ -70,7 +70,7 @@
  {
 --- a/boot/image-fit.c
 +++ b/boot/image-fit.c
-@@ -2051,6 +2051,49 @@ static const char *fit_get_image_type_pr
+@@ -2051,6 +2051,47 @@ static const char *fit_get_image_type_pr
        return "unknown";
  }
  
 +      max_size = hdrsize;
 +
 +      images_noffset = fdt_path_offset(fit, FIT_IMAGES_PATH);
-+      if (images_noffset < 0) {
-+              printf("Can't find images parent node '%s' (%s)\n",
-+              FIT_IMAGES_PATH, fdt_strerror(images_noffset));
-+              return 0;
-+      }
++      if (images_noffset < 0)
++              goto out;
 +
 +      for (ndepth = 0,
 +           noffset = fdt_next_node(fit, images_noffset, &ndepth);
 +              if (ndepth == 1) {
 +                      ret = fit_image_get_data_and_size(fit, noffset, &data, &data_size);
 +                      if (ret)
-+                              return 0;
++                              goto out;
 +
 +                      img_total = data_size + (data - fit);
 +
 +              }
 +      }
 +
++out:
 +      return max_size;
 +}
 +