mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-31 04:01:48 -04:00
remoteproc: make sure we're parsing a 32bit firmware
Make sure we're parsing a 32bit image, since we only support the ELF32 binary format at this point. This should prevent unexpected behavior with non 32bit binaries. Signed-off-by: Ohad Ben-Cohen <[email protected]> Cc: Grant Likely <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Mark Grosen <[email protected]> Cc: Suman Anna <[email protected]> Cc: Fernando Guzman Lugo <[email protected]> Cc: Rob Clark <[email protected]> Cc: Ludovic BARRE <[email protected]> Cc: Loic PALLARDY <[email protected]> Cc: Omar Ramirez Luna <[email protected]>
This commit is contained in:
parent
e12bc14b88
commit
40b78b2cc7
1 changed files with 8 additions and 0 deletions
|
|
@ -840,6 +840,7 @@ static int rproc_fw_sanity_check(struct rproc *rproc, const struct firmware *fw)
|
|||
const char *name = rproc->firmware;
|
||||
struct device *dev = rproc->dev;
|
||||
struct elf32_hdr *ehdr;
|
||||
char class;
|
||||
|
||||
if (!fw) {
|
||||
dev_err(dev, "failed to load %s\n", name);
|
||||
|
|
@ -853,6 +854,13 @@ static int rproc_fw_sanity_check(struct rproc *rproc, const struct firmware *fw)
|
|||
|
||||
ehdr = (struct elf32_hdr *)fw->data;
|
||||
|
||||
/* We only support ELF32 at this point */
|
||||
class = ehdr->e_ident[EI_CLASS];
|
||||
if (class != ELFCLASS32) {
|
||||
dev_err(dev, "Unsupported class: %d\n", class);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* We assume the firmware has the same endianess as the host */
|
||||
# ifdef __LITTLE_ENDIAN
|
||||
if (ehdr->e_ident[EI_DATA] != ELFDATA2LSB) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue