]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
bootstd: Init the size before reading the devicetree
authorSimon Glass <sjg@chromium.org>
Thu, 27 Jul 2023 03:01:24 +0000 (21:01 -0600)
committerTom Rini <trini@konsulko.com>
Thu, 3 Aug 2023 19:30:54 +0000 (15:30 -0400)
The implementation in distro_efi_try_bootflow_files() does not pass a
valid size to bootmeth_common_read_file(), so this can fail if the
uninted value happens to be too small.

Fix this.

This was reported by someone but I cannot now find the email.

Signed-off-by: Simon Glass <sjg@chromium.org>
boot/bootmeth_efi.c

index bceec0d12ef30fb930a5f5f90ae0e84626356a7f..1c9f2b1e2fe41b231b21f94a29ace4bab61344f8 100644 (file)
@@ -21,6 +21,7 @@
 #include <mmc.h>
 #include <net.h>
 #include <pxe_utils.h>
+#include <linux/sizes.h>
 
 #define EFI_DIRNAME    "efi/boot/"
 
@@ -281,9 +282,12 @@ static int distro_efi_try_bootflow_files(struct udevice *dev,
                ret = distro_efi_get_fdt_name(fname, sizeof(fname), seq);
                if (ret == -EALREADY)
                        bflow->flags = BOOTFLOWF_USE_PRIOR_FDT;
-               if (!ret)
+               if (!ret) {
+                       /* Limit FDT files to 4MB */
+                       size = SZ_4M;
                        ret = bootmeth_common_read_file(dev, bflow, fname,
                                                        fdt_addr, &size);
+               }
        }
 
        if (*fname) {