Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 9f9967fed9d0 ("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>

authored by

Dan Carpenter and committed by
Bjorn Andersson
9f35ab0e 9cea10a4

+2 -2
+2 -2
drivers/soc/qcom/mdt_loader.c
··· 33 33 return false; 34 34 35 35 if (ehdr->e_phentsize != sizeof(struct elf32_phdr)) 36 - return -EINVAL; 36 + return false; 37 37 38 38 phend = size_add(size_mul(sizeof(struct elf32_phdr), ehdr->e_phnum), ehdr->e_phoff); 39 39 if (phend > fw->size) 40 40 return false; 41 41 42 42 if (ehdr->e_shentsize != sizeof(struct elf32_shdr)) 43 - return -EINVAL; 43 + return false; 44 44 45 45 shend = size_add(size_mul(sizeof(struct elf32_shdr), ehdr->e_shnum), ehdr->e_shoff); 46 46 if (shend > fw->size)