2002-11-20 08:42:36

by Greg KH

[permalink] [raw]
Subject: Can't allocate memory when loading a module 2.5.48-bk

With Linus's latest bk tree (plus some USB patches) I get the following
error when trying to load the parport.o module:

# modprobe parport
FATAL: Error inserting /lib/modules/2.5.48/kernel/parport.o: Cannot allocate memory

Any ideas?

thanks,

greg k-h


2002-11-20 09:08:00

by Jari Ruusu

[permalink] [raw]
Subject: Re: Can't allocate memory when loading a module 2.5.48-bk

Greg KH wrote:
> With Linus's latest bk tree (plus some USB patches) I get the following
> error when trying to load the parport.o module:
>
> # modprobe parport
> FATAL: Error inserting /lib/modules/2.5.48/kernel/parport.o: Cannot allocate memory
>
> Any ideas?

Tag some init code with __init

At least stock 2.5.48 tries to happily allocate zero bytes for init section,
and gets a null pointer. That 'error' is then propagated to user space.

Regards,
Jari Ruusu <[email protected]>

2002-11-20 12:45:03

by Juan M. de la Torre

[permalink] [raw]
Subject: Re: Can't allocate memory when loading a module 2.5.48-bk

On Wed, Nov 20, 2002 at 12:43:03AM -0800, Greg KH wrote:
> With Linus's latest bk tree (plus some USB patches) I get the following
> error when trying to load the parport.o module:
>
> # modprobe parport
> FATAL: Error inserting /lib/modules/2.5.48/kernel/parport.o: Cannot allocate memory
>
> Any ideas?

Try applying this patch:

--- linux-2.5.48/kernel/module.c.orig Tue Nov 19 20:08:52 2002
+++ linux-2.5.48/kernel/module.c Tue Nov 19 20:37:47 2002
@@ -972,13 +972,15 @@
memset(ptr, 0, mod->core_size);
mod->module_core = ptr;

- ptr = module_alloc(mod->init_size);
- if (!ptr) {
- err = -ENOMEM;
- goto free_core;
- }
- memset(ptr, 0, mod->init_size);
- mod->module_init = ptr;
+ if (mod->init_size) {
+ ptr = module_alloc(mod->init_size);
+ if (!ptr) {
+ err = -ENOMEM;
+ goto free_core;
+ }
+ memset(ptr, 0, mod->init_size);
+ mod->module_init = ptr;
+ }

/* Transfer each section which requires ALLOC, and set sh_offset
fields to absolute addresses. */

--
/jm

2002-11-25 00:24:01

by Rusty Russell

[permalink] [raw]
Subject: Re: Can't allocate memory when loading a module 2.5.48-bk

In message <[email protected]> you write:
> With Linus's latest bk tree (plus some USB patches) I get the following
> error when trying to load the parport.o module:
>
> # modprobe parport
> FATAL: Error inserting /lib/modules/2.5.48/kernel/parport.o: Cannot allocate
memory
>
> Any ideas?

No init section, my bad. Should be fixed in 49.

Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.