aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/remoteproc/remoteproc_core.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index 6212b82885d0..567a3c59b4af 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -39,6 +39,7 @@
39#include <linux/elf.h> 39#include <linux/elf.h>
40#include <linux/virtio_ids.h> 40#include <linux/virtio_ids.h>
41#include <linux/virtio_ring.h> 41#include <linux/virtio_ring.h>
42#include <asm/byteorder.h>
42 43
43#include "remoteproc_internal.h" 44#include "remoteproc_internal.h"
44 45
@@ -851,6 +852,16 @@ static int rproc_fw_sanity_check(struct rproc *rproc, const struct firmware *fw)
851 852
852 ehdr = (struct elf32_hdr *)fw->data; 853 ehdr = (struct elf32_hdr *)fw->data;
853 854
855 /* We assume the firmware has the same endianess as the host */
856# ifdef __LITTLE_ENDIAN
857 if (ehdr->e_ident[EI_DATA] != ELFDATA2LSB) {
858# else /* BIG ENDIAN */
859 if (ehdr->e_ident[EI_DATA] != ELFDATA2MSB) {
860# endif
861 dev_err(dev, "Unsupported firmware endianess\n");
862 return -EINVAL;
863 }
864
854 if (fw->size < ehdr->e_shoff + sizeof(struct elf32_shdr)) { 865 if (fw->size < ehdr->e_shoff + sizeof(struct elf32_shdr)) {
855 dev_err(dev, "Image is too small\n"); 866 dev_err(dev, "Image is too small\n");
856 return -EINVAL; 867 return -EINVAL;