2
0
mirror of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git synced 2025-09-04 20:19:47 +08:00

soc: qcom: mdt_loader: Fix error return values in mdt_header_valid()

This function is supposed to return true for valid headers and false for
invalid.  In a couple places it returns -EINVAL instead which means the
invalid headers are counted as true.  Change it to return false.

Fixes: 9f9967fed9 ("soc: qcom: mdt_loader: Ensure we don't read past the ELF header")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Link: https://lore.kernel.org/r/db57c01c-bdcc-4a0f-95db-b0f2784ea91f@sabinyo.mountain
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
This commit is contained in:
Dan Carpenter 2025-06-25 10:22:41 -05:00 committed by Bjorn Andersson
parent 9cea10a4f5
commit 9f35ab0e53

View File

@ -33,14 +33,14 @@ static bool mdt_header_valid(const struct firmware *fw)
return false; return false;
if (ehdr->e_phentsize != sizeof(struct elf32_phdr)) if (ehdr->e_phentsize != sizeof(struct elf32_phdr))
return -EINVAL; return false;
phend = size_add(size_mul(sizeof(struct elf32_phdr), ehdr->e_phnum), ehdr->e_phoff); phend = size_add(size_mul(sizeof(struct elf32_phdr), ehdr->e_phnum), ehdr->e_phoff);
if (phend > fw->size) if (phend > fw->size)
return false; return false;
if (ehdr->e_shentsize != sizeof(struct elf32_shdr)) if (ehdr->e_shentsize != sizeof(struct elf32_shdr))
return -EINVAL; return false;
shend = size_add(size_mul(sizeof(struct elf32_shdr), ehdr->e_shnum), ehdr->e_shoff); shend = size_add(size_mul(sizeof(struct elf32_shdr), ehdr->e_shnum), ehdr->e_shoff);
if (shend > fw->size) if (shend > fw->size)