Query regarding Kmemleak

Smital Desai Smital.Desai at lntinfotech.com
Tue Jan 31 19:01:34 EST 2012


Hello ,

         I am  just trying to understand Kmemleak support.

         In a test program ,  allocating some memory using and vmalloc () and freeing it in exit () routine.
         But when i run a kmemleak , It reports this as a leak.

         But isn't it a generic reuirement to allocate something for the lifetime of the module and free when we remove the module. ?   Can somebody explain ?

         I have provided the kmemleak output and my test program below.

Thanks,
Smital Desai


=================================================================================

cat  /sys/kernel/debug/memleak

unreferenced object 0xe1b18000 (size 512):
  comm "insmod", pid 1066, jiffies 4294953148 (age 54.630s)
  hex dump (first 32 bytes):
    36 1c 00 00 02 16 00 00 3c 1c 00 00 02 16 00 00  6.......<.......
    43 1c 00 00 02 16 00 00 4f 1c 00 00 02 16 00 00  C.......O.......
  backtrace:
    [<c0234ecc>] __vmalloc_node_range+0x1a8/0x1d0
    [<c0234f2c>] __vmalloc_node+0x38/0x44
    [<c023507c>] vmalloc+0x28/0x30
    [<bf00200c>] 0xbf00200c
    [<c0100458>] do_one_initcall+0x94/0x164
    [<c01d639c>] sys_init_module+0x70/0x190
    [<c0105d60>] ret_fast_syscall+0x0/0x30
    [<ffffffff>] 0xffffffff
unreferenced object 0xe1b1a000 (size 512):
  comm "insmod", pid 1066, jiffies 4294953148 (age 54.630s)
  hex dump (first 32 bytes):
    00 00 00 00 00 2c 00 00 00 00 00 00 2a 03 00 00  .....,......*...
    00 00 00 00 00 2c 00 00 bc 00 00 00 02 2e 00 00  .....,..........
  backtrace:
    [<c0234ecc>] __vmalloc_node_range+0x1a8/0x1d0
    [<c0234f2c>] __vmalloc_node+0x38/0x44
    [<c023507c>] vmalloc+0x28/0x30
    [<bf00201c>] 0xbf00201c
    [<c0100458>] do_one_initcall+0x94/0x164
    [<c01d639c>] sys_init_module+0x70/0x190
    [<c0105d60>] ret_fast_syscall+0x0/0x30
    [<ffffffff>] 0xffffffff
=====================================================================================



                                                            "test.c"
==================================================================================
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/kmemleak.h>

char *ptr1, *ptr2;

/*
 * Some very simple testing. This function needs to be extended for
 * proper testing.
 */
static int __init kmemleak_test_init(void)
{
        ptr1 = vmalloc(512);
        ptr2 = vmalloc(512);

        return 0;
}
module_init(kmemleak_test_init);

static void __exit kmemleak_test_exit(void)
{
       vfree(ptr1);
       vfree(ptr2);
}
module_exit(kmemleak_test_exit);

MODULE_LICENSE("GPL");
==================================================================================



Thanks and Regard
 Smital Desai

The contents of this e-mail and any attachment(s) may contain confidential or privileged information for the intended recipient(s). Unintended recipients are prohibited from taking action on the basis of information in this e-mail and  using or disseminating the information,  and must notify the sender and delete it from their system. L&T Infotech will not accept responsibility or liability for the accuracy or completeness of, or the presence of any virus or disabling code in this e-mail"



More information about the Kernelnewbies mailing list