summaryrefslogtreecommitdiff
path: root/arch/mips/kernel/module.c
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2016-05-04 14:41:51 +0100
committerMark Brown <broonie@kernel.org>2016-05-04 14:41:51 +0100
commit3d277b177918cd26215732fc23af0783ab4b37dd (patch)
tree2033b4f517415e9e68eb066fa073b79a3884e03d /arch/mips/kernel/module.c
parentf55532a0c0b8bb6148f4e07853b876ef73bc69ca (diff)
parent02da2d72174c61988eb4456b53f405e3ebdebce4 (diff)
Merge tag 'v4.6-rc5' into spi-rockchip
Linux 4.6-rc5
Diffstat (limited to 'arch/mips/kernel/module.c')
-rw-r--r--arch/mips/kernel/module.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/arch/mips/kernel/module.c b/arch/mips/kernel/module.c
index 1833f5171ccd..f9b2936d598d 100644
--- a/arch/mips/kernel/module.c
+++ b/arch/mips/kernel/module.c
@@ -197,9 +197,10 @@ int apply_relocate(Elf_Shdr *sechdrs, const char *strtab,
struct module *me)
{
Elf_Mips_Rel *rel = (void *) sechdrs[relsec].sh_addr;
+ int (*handler)(struct module *me, u32 *location, Elf_Addr v);
Elf_Sym *sym;
u32 *location;
- unsigned int i;
+ unsigned int i, type;
Elf_Addr v;
int res;
@@ -223,9 +224,21 @@ int apply_relocate(Elf_Shdr *sechdrs, const char *strtab,
return -ENOENT;
}
- v = sym->st_value;
+ type = ELF_MIPS_R_TYPE(rel[i]);
+
+ if (type < ARRAY_SIZE(reloc_handlers_rel))
+ handler = reloc_handlers_rel[type];
+ else
+ handler = NULL;
- res = reloc_handlers_rel[ELF_MIPS_R_TYPE(rel[i])](me, location, v);
+ if (!handler) {
+ pr_err("%s: Unknown relocation type %u\n",
+ me->name, type);
+ return -EINVAL;
+ }
+
+ v = sym->st_value;
+ res = handler(me, location, v);
if (res)
return res;
}