error inserting a module in Linux -- 1 Cannot allocate memory

10,076

Solution 1

A likely cause of something like this happening is if one recompiles and installs a kernel and its modules but forgets to mount /boot before installing the kernel. After a reboot, one will then run with the old kernel but new modules. In any event, check that the running kernel is current, and reinstall both the kernel and the modules if in doubt:

mount /boot 
cd /usr/src/linux 
make && make install && make modules_install 

I have done the above steps and error was solved

Solution 2

Start with the error you are seeing in dmesg:

kmem_cache_create: duplicate cache ecryptfs_auth_tok_list_item

When the ecryptfs module is loaded the first thing it does is create a bunch of memory caches for itself. The error suggests that there is already a cache with that name.

You can check if the cache already exists by looking at sysfs:

$ ls -ld /sys/kernel/slab/ecryptfs*

NB. It may not show up in /proc/slabinfo due to slab merging.

If you see any ecryptfs slabs that suggests the ecryptfs module is already loaded, or it is already built into your kernel.

Normally the module loader would not let you load the same module twice, but perhaps you have done something weird to confuse it.

Share:
10,076
rookie_developer
Author by

rookie_developer

Updated on June 05, 2022

Comments

  • rookie_developer
    rookie_developer almost 2 years

    eCryptfs is a POSIX-compliant encrypted filesystem that has been part of the mainline Linux Kernel since version 2.6.19.

    When I try to insert the module (ecryptfs.ko), I get the following error:

    insmod: error inserting 'ecryptfs.ko': -1 Cannot allocate memory

    Can some one please help me out?

    below is the dmesg

    Failed to allocate one or more kmem_cache objects
    
    kmem_cache_create: duplicate cache ecryptfs_auth_tok_list_item
    
    Pid: 3332, comm: insmod Tainted: G           O 3.2.2+ #1
    
    Call Trace:
    
    [<c102bfe0>] ? printk+0x15/0x17
    
    [<c10878b6>] kmem_cache_create+0x41c/0x458
    
    [<d0ebd038>] ecryptfs_init+0x38/0x1b1 [ecryptfs]
    
    [<c1001071>] do_one_initcall+0x71/0x118
    
    [<d0ebd000>] ? 0xd0ebcfff
    
    [<c1055703>] sys_init_module+0x60/0x18c
    
    [<c12db9b0>] sysenter_do_call+0x12/0x36
    
    ecryptfs_init_kmem_caches: ecryptfs_auth_tok_list_item: kmem_cache_create 
    failed
    
     Failed to allocate one or more kmem_cache objects