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

Commit 82fab442 authored by Rusty Russell's avatar Rusty Russell
Browse files

modules: don't hand 0 to vmalloc.

In commit d0a21265 David Rientjes unified various archs'
module_alloc implementation (including x86) and removed the graduitous
shortcut for size == 0.

Then, in commit de7d2b56, Joe Perches added a warning for
zero-length vmallocs, which can happen without kallsyms on modules
with no init sections (eg. zlib_deflate).

Fix this once and for all; the module code has to handle zero length
anyway, so get it right at the caller and remove the now-gratuitous
checks within the arch-specific module_alloc implementations.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=42608


Reported-by: default avatarConrad Kostecki <ConiKost@gmx.de>
Cc: David Rientjes <rientjes@google.com>
Cc: Joe Perches <joe@perches.com>
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
parent 54523ec7
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -32,8 +32,6 @@
#ifdef CONFIG_ETRAX_KMALLOCED_MODULES
void *module_alloc(unsigned long size)
{
	if (size == 0)
		return NULL;
	return kmalloc(size, GFP_KERNEL);
}

+0 −2
Original line number Diff line number Diff line
@@ -214,8 +214,6 @@ static inline int reassemble_22(int as22)

void *module_alloc(unsigned long size)
{
	if (size == 0)
		return NULL;
	/* using RWX means less protection for modules, but it's
	 * easier than trying to map the text, data, init_text and
	 * init_data correctly */
+0 −4
Original line number Diff line number Diff line
@@ -43,10 +43,6 @@ void *module_alloc(unsigned long size)
{
	void *ret;

	/* We handle the zero case fine, unlike vmalloc */
	if (size == 0)
		return NULL;

	ret = module_map(size);
	if (ret)
		memset(ret, 0, size);
+0 −2
Original line number Diff line number Diff line
@@ -42,8 +42,6 @@ void *module_alloc(unsigned long size)
	int i = 0;
	int npages;

	if (size == 0)
		return NULL;
	npages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
	pages = kmalloc(npages * sizeof(struct page *), GFP_KERNEL);
	if (pages == NULL)
+0 −3
Original line number Diff line number Diff line
@@ -27,9 +27,6 @@ void *module_alloc(unsigned long size)
	struct vm_struct *area;

	size = PAGE_ALIGN(size);
	if (!size)
		return NULL;

	area = __get_vm_area(size, VM_ALLOC, MODULES_VADDR, MODULES_END);
	if (!area)
		return NULL;
Loading