]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
image: Remove some #ifdefs from image-fit and image-fit-sig
authorSimon Glass <sjg@chromium.org>
Sun, 26 Sep 2021 01:43:39 +0000 (19:43 -0600)
committerTom Rini <trini@konsulko.com>
Fri, 8 Oct 2021 19:53:27 +0000 (15:53 -0400)
Drop the #ifdefs which are easy to remove without refactoring.

Signed-off-by: Simon Glass <sjg@chromium.org>
common/Kconfig.boot
common/image-fit-sig.c
common/image-fit.c

index f23b99885212ab82dc2ee5428870bd1cd0535843..9b84a8d005f78c73ef2a555e374ce9b6a6dfab56 100644 (file)
@@ -165,6 +165,16 @@ config SPL_FIT_SIGNATURE
        select SPL_IMAGE_SIGN_INFO
        select SPL_FIT_FULL_CHECK
 
+config SPL_FIT_SIGNATURE_MAX_SIZE
+       hex "Max size of signed FIT structures in SPL"
+       depends on SPL_FIT_SIGNATURE
+       default 0x10000000
+       help
+         This option sets a max size in bytes for verified FIT uImages.
+         A sane value of 256MB protects corrupted DTB structures from overlapping
+         device memory. Assure this size does not extend past expected storage
+         space.
+
 config SPL_LOAD_FIT
        bool "Enable SPL loading U-Boot as a FIT (basic fitImage features)"
        select SPL_FIT
index e95e64bd2fe92da8b14e2e84445dec837ff2979d..4edebbf2d32a30aabe1121475e749e477216e7bf 100644 (file)
@@ -49,10 +49,8 @@ struct image_region *fit_region_make_list(const void *fit,
         * Use malloc() except in SPL (to save code size). In SPL the caller
         * must allocate the array.
         */
-#ifndef CONFIG_SPL_BUILD
-       if (!region)
+       if (!IS_ENABLED(CONFIG_SPL_BUILD) && !region)
                region = calloc(sizeof(*region), count);
-#endif
        if (!region)
                return NULL;
        for (i = 0; i < count; i++) {
@@ -72,12 +70,10 @@ static int fit_image_setup_verify(struct image_sign_info *info,
        char *algo_name;
        const char *padding_name;
 
-#ifndef USE_HOSTCC
-       if (fdt_totalsize(fit) > CONFIG_FIT_SIGNATURE_MAX_SIZE) {
+       if (fdt_totalsize(fit) > CONFIG_VAL(FIT_SIGNATURE_MAX_SIZE)) {
                *err_msgp = "Total size too large";
                return 1;
        }
-#endif
        if (fit_image_hash_get_algo(fit, noffset, &algo_name)) {
                *err_msgp = "Can't get hash algo property";
                return -1;
index 1e4099d127aa764e4454405a3b7ffbee1c80e99d..33b4a46028b2b3da3f907d9f2c46ae71871bba00 100644 (file)
@@ -2009,9 +2009,6 @@ int fit_image_load(bootm_headers_t *images, ulong addr,
        int type_ok, os_ok;
        ulong load, load_end, data, len;
        uint8_t os, comp;
-#ifndef USE_HOSTCC
-       uint8_t os_arch;
-#endif
        const char *prop_name;
        int ret;
 
@@ -2103,8 +2100,12 @@ int fit_image_load(bootm_headers_t *images, ulong addr,
        }
 
 #ifndef USE_HOSTCC
+       {
+       uint8_t os_arch;
+
        fit_image_get_arch(fit, noffset, &os_arch);
        images->os.arch = os_arch;
+       }
 #endif
 
        bootstage_mark(bootstage_id + BOOTSTAGE_SUB_CHECK_ALL);