spl: fit: Skip attempting to load 0 length image

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>
This commit is contained in:
Nishanth Menon 2021-10-19 12:32:29 -05:00 committed by Tom Rini
parent af13df7014
commit 6d99f86695

View File

@ -286,6 +286,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;
}
src_ptr = map_sysmem(ALIGN(load_addr, ARCH_DMA_MINALIGN), len);
length = len;