kernel: fix crashes on MIPS when loading kernel modules under memory pressure
[openwrt/openwrt.git] / target / linux / generic / patches-4.9 / 305-mips_module_reloc.patch
index 997105ba1aa386b2b44239fa25623430ceee8457..1c2bd0aa9f23cfb5cfb5f4664cc151ef52f2888f 100644 (file)
  
        return 0;
  }
-@@ -349,9 +591,33 @@ int module_finalize(const Elf_Ehdr *hdr,
+@@ -349,9 +591,36 @@ int module_finalize(const Elf_Ehdr *hdr,
                list_add(&me->arch.dbe_list, &dbe_list);
                spin_unlock_irq(&dbe_lock);
        }
  
 +void module_arch_freeing_init(struct module *mod)
 +{
++      if (mod->state == MODULE_STATE_LIVE)
++              return;
++
 +      if (mod->arch.phys_plt_tbl) {
 +              __module_free(mod->arch.phys_plt_tbl);
 +              mod->arch.phys_plt_tbl = NULL;