Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d453cded authored by Rusty Russell's avatar Rusty Russell
Browse files

module_arch_freeing_init(): new hook for archs before module->module_init freed.



Archs have been abusing module_free() to clean up their arch-specific
allocations.  Since module_free() is also (ab)used by BPF and trace code,
let's keep it to simple allocations, and provide a hook called before
that.

This means that avr32, ia64, parisc and s390 no longer need to implement
their own module_free() at all.  avr32 doesn't need module_finalize()
either.

Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
Cc: Chris Metcalf <cmetcalf@ezchip.com>
Cc: Haavard Skinnemoen <hskinnemoen@gmail.com>
Cc: Hans-Christian Egtvedt <egtvedt@samfundet.no>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: "James E.J. Bottomley" <jejb@parisc-linux.org>
Cc: Helge Deller <deller@gmx.de>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: linux-kernel@vger.kernel.org
Cc: linux-ia64@vger.kernel.org
Cc: linux-parisc@vger.kernel.org
Cc: linux-s390@vger.kernel.org
parent c772be52
Loading
Loading
Loading
Loading
+1 −12
Original line number Diff line number Diff line
@@ -19,12 +19,10 @@
#include <linux/moduleloader.h>
#include <linux/vmalloc.h>

void module_free(struct module *mod, void *module_region)
void module_arch_freeing_init(struct module *mod)
{
	vfree(mod->arch.syminfo);
	mod->arch.syminfo = NULL;

	vfree(module_region);
}

static inline int check_rela(Elf32_Rela *rela, struct module *module,
@@ -291,12 +289,3 @@ int apply_relocate_add(Elf32_Shdr *sechdrs, const char *strtab,

	return ret;
}

int module_finalize(const Elf_Ehdr *hdr, const Elf_Shdr *sechdrs,
		    struct module *module)
{
	vfree(module->arch.syminfo);
	module->arch.syminfo = NULL;

	return 0;
}
+2 −4
Original line number Diff line number Diff line
@@ -305,14 +305,12 @@ plt_target (struct plt_entry *plt)
#endif /* !USE_BRL */

void
module_free (struct module *mod, void *module_region)
module_arch_freeing_init (struct module *mod)
{
	if (mod && mod->arch.init_unw_table &&
	    module_region == mod->module_init) {
	if (mod->arch.init_unw_table) {
		unw_remove_unwind_table(mod->arch.init_unw_table);
		mod->arch.init_unw_table = NULL;
	}
	vfree(module_region);
}

/* Have we already seen one of these relocations? */
+1 −5
Original line number Diff line number Diff line
@@ -298,14 +298,10 @@ static inline unsigned long count_stubs(const Elf_Rela *rela, unsigned long n)
}
#endif


/* Free memory returned from module_alloc */
void module_free(struct module *mod, void *module_region)
void module_arch_freeing_init(struct module *mod)
{
	kfree(mod->arch.section);
	mod->arch.section = NULL;

	vfree(module_region);
}

/* Additional bytes needed in front of individual sections */
+3 −7
Original line number Diff line number Diff line
@@ -55,15 +55,11 @@ void *module_alloc(unsigned long size)
}
#endif

/* Free memory returned from module_alloc */
void module_free(struct module *mod, void *module_region)
void module_arch_freeing_init(struct module *mod)
{
	if (mod) {
	vfree(mod->arch.syminfo);
	mod->arch.syminfo = NULL;
}
	vfree(module_region);
}

static void check_rela(Elf_Rela *rela, struct module *me)
{
+1 −1
Original line number Diff line number Diff line
@@ -83,7 +83,7 @@ void module_free(struct module *mod, void *module_region)
		     0, 0, 0, NULL, NULL, 0);

	/*
	 * FIXME: If module_region == mod->module_init, trim exception
	 * FIXME: Add module_arch_freeing_init to trim exception
	 * table entries.
	 */
}
Loading