MIPS: Bail on unsupported module relocs
[deliverable/linux.git] / arch / mips / kernel / module-rela.c
index 2b70723071c322018dbb616a0b158bae4da85d0e..9083d63b765cf9532f3a7e42f892a3b90b50811a 100644 (file)
@@ -109,9 +109,10 @@ int apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab,
                       struct module *me)
 {
        Elf_Mips_Rela *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;
 
@@ -134,9 +135,21 @@ int apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab,
                        return -ENOENT;
                }
 
-               v = sym->st_value + rel[i].r_addend;
+               type = ELF_MIPS_R_TYPE(rel[i]);
+
+               if (type < ARRAY_SIZE(reloc_handlers_rela))
+                       handler = reloc_handlers_rela[type];
+               else
+                       handler = NULL;
 
-               res = reloc_handlers_rela[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 + rel[i].r_addend;
+               res = handler(me, location, v);
                if (res)
                        return res;
        }
This page took 0.026179 seconds and 5 git commands to generate.