[PATCH 4/5] bootstd: Init the size before reading the devicetree
Simon Glass
sjg at chromium.org
Thu Jul 27 05:01:24 CEST 2023
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 at chromium.org>
---
boot/bootmeth_efi.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c
index bceec0d12ef3..1c9f2b1e2fe4 100644
--- a/boot/bootmeth_efi.c
+++ b/boot/bootmeth_efi.c
@@ -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) {
--
2.41.0.487.g6d72f3e995-goog
More information about the U-Boot
mailing list