MIPS: Bail on unsupported module relocs
[deliverable/linux.git] / arch / mips / kernel / module.c
index 1833f5171ccda092a74f6ac6a902d30e397fc985..f9b2936d598def20f5f9be027a4b1e1a8af758c4 100644 (file)
@@ -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;
        }
This page took 0.027577 seconds and 5 git commands to generate.