kernel: fix crashes on MIPS when loading kernel modules under memory pressure
[openwrt/staging/yousong.git] / target / linux / generic / patches-3.18 / 305-mips_module_reloc.patch
index 41cf80671b4c5c6b29ea115173dafebd29290a8c..fae7e70f0e54ea37b458419674b271a9bacf081a 100644 (file)
  
        return 0;
  }
-@@ -287,11 +529,32 @@ int module_finalize(const Elf_Ehdr *hdr,
+@@ -287,9 +529,36 @@ int module_finalize(const Elf_Ehdr *hdr,
                list_add(&me->arch.dbe_list, &dbe_list);
                spin_unlock_irq(&dbe_lock);
        }
        return 0;
  }
  
- void module_arch_cleanup(struct module *mod)
- {
++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;
 +              __module_free(mod->arch.virt_plt_tbl);
 +              mod->arch.virt_plt_tbl = NULL;
 +      }
++}
 +
+ void module_arch_cleanup(struct module *mod)
+ {
        spin_lock_irq(&dbe_lock);
-       list_del(&mod->arch.dbe_list);
-       spin_unlock_irq(&dbe_lock);