summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorNishanth Menon <nm@ti.com>2022-01-04 14:35:02 -0600
committerPraneeth Bajjuri <praneeth@ti.com>2022-01-04 14:41:34 -0600
commit4cfd609f8df1e9d1ef57a97855339a3f360bb079 (patch)
treeb0498aee40cfc750f8513aeed137e40805ab48ea /common
parent816bdfe2569dba23816181926162aab444aa35c2 (diff)
spl: fit: Skip attempting to load 0 length image
commit 6d99f866952bb5df7fe699b3db29a97d75e5c445 upstream. When, for various reasons, a bad FIT image is used where a loadable image is marked as 0 length, attempt is made for a 0 length allocation and read of 0 byte read operation. Instead provide warning in log and skip attempting to do such a load. Signed-off-by: Nishanth Menon <nm@ti.com> Reviewed-by: Aswath Govindraju <a-govindraju@ti.com> [praneeth@ti.com: forward port commit '6d99f866952b' from upstream u-boot/next] Signed-off-by: Praneeth Bajjuri <praneeth@ti.com>
Diffstat (limited to 'common')
-rw-r--r--common/spl/spl_fit.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index 55511a90d0..f711c8ef4f 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -282,6 +282,13 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
if (fit_image_get_data_size(fit, node, &len))
return -ENOENT;
+ /* Dont bother to copy 0 byte data, but warn, though */
+ if (!len) {
+ log_warning("%s: Skip load '%s': image size is 0!\n",
+ __func__, fit_get_name(fit, node, NULL));
+ return 0;
+ }
+
load_ptr = (load_addr + align_len) & ~align_len;
length = len;