1
0
mirror of https://xff.cz/git/u-boot/ synced 2025-09-01 16:52:14 +02:00

remoteproc: elf_loader: Always check the validity of the image before loading

rproc_elf32_load_image() rely on user to send a valid address for elf loading.
Instead do a sanity check on the address passed by user. This will help
all rproc elf users to not call sanity_check explicitly before calling
elf_loading.

Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
Reviewed-by: Fabien Dessenne <fabien.dessenne@st.com>
This commit is contained in:
Lokesh Vutla
2019-09-04 16:01:28 +05:30
committed by Tom Rini
parent c08eb93626
commit 14d963d1b5
4 changed files with 14 additions and 17 deletions

View File

@@ -64,13 +64,18 @@ int rproc_elf32_sanity_check(ulong addr, ulong size)
return 0;
}
/* A very simple elf loader, assumes the image is valid */
int rproc_elf32_load_image(struct udevice *dev, unsigned long addr)
int rproc_elf32_load_image(struct udevice *dev, unsigned long addr, ulong size)
{
Elf32_Ehdr *ehdr; /* Elf header structure pointer */
Elf32_Phdr *phdr; /* Program header structure pointer */
const struct dm_rproc_ops *ops;
unsigned int i;
unsigned int i, ret;
ret = rproc_elf32_sanity_check(addr, size);
if (ret) {
dev_err(dev, "Invalid ELF32 Image %d\n", ret);
return ret;
}
ehdr = (Elf32_Ehdr *)addr;
phdr = (Elf32_Phdr *)(addr + ehdr->e_phoff);