diff options
author | Ohad Ben-Cohen <ohad@wizery.com> | 2012-02-13 16:12:24 -0500 |
---|---|---|
committer | Ohad Ben-Cohen <ohad@wizery.com> | 2012-02-28 11:03:40 -0500 |
commit | 40b78b2cc75315a76ab1863be744d8580030f924 (patch) | |
tree | ca7b9a5299fd5346c61491e333491354beb92794 /drivers/remoteproc | |
parent | e12bc14b88d44e5c1456dccb59ff58103f6c6edc (diff) |
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 <ohad@wizery.com>
Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Mark Grosen <mgrosen@ti.com>
Cc: Suman Anna <s-anna@ti.com>
Cc: Fernando Guzman Lugo <fernando.lugo@ti.com>
Cc: Rob Clark <rob@ti.com>
Cc: Ludovic BARRE <ludovic.barre@stericsson.com>
Cc: Loic PALLARDY <loic.pallardy@stericsson.com>
Cc: Omar Ramirez Luna <omar.luna@linaro.org>
Diffstat (limited to 'drivers/remoteproc')
-rw-r--r-- | drivers/remoteproc/remoteproc_core.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 729911b67a9a..8990c51c16f0 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c | |||
@@ -840,6 +840,7 @@ static int rproc_fw_sanity_check(struct rproc *rproc, const struct firmware *fw) | |||
840 | const char *name = rproc->firmware; | 840 | const char *name = rproc->firmware; |
841 | struct device *dev = rproc->dev; | 841 | struct device *dev = rproc->dev; |
842 | struct elf32_hdr *ehdr; | 842 | struct elf32_hdr *ehdr; |
843 | char class; | ||
843 | 844 | ||
844 | if (!fw) { | 845 | if (!fw) { |
845 | dev_err(dev, "failed to load %s\n", name); | 846 | 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) | |||
853 | 854 | ||
854 | ehdr = (struct elf32_hdr *)fw->data; | 855 | ehdr = (struct elf32_hdr *)fw->data; |
855 | 856 | ||
857 | /* We only support ELF32 at this point */ | ||
858 | class = ehdr->e_ident[EI_CLASS]; | ||
859 | if (class != ELFCLASS32) { | ||
860 | dev_err(dev, "Unsupported class: %d\n", class); | ||
861 | return -EINVAL; | ||
862 | } | ||
863 | |||
856 | /* We assume the firmware has the same endianess as the host */ | 864 | /* We assume the firmware has the same endianess as the host */ |
857 | # ifdef __LITTLE_ENDIAN | 865 | # ifdef __LITTLE_ENDIAN |
858 | if (ehdr->e_ident[EI_DATA] != ELFDATA2LSB) { | 866 | if (ehdr->e_ident[EI_DATA] != ELFDATA2LSB) { |