Exact leak location in KMemleak Output

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I have an out of tree kernel module with the source:

static __init int hello_init(void)
{
       char *ptr;
       ptr = vmalloc(512);
       ptr = vmalloc(512);
       ptr = vmalloc(512);

       printk(KERN_ALERT "Hello World");

       return 0;
}

Now I compile this file (hello.c) using my Makefile as follows:

EXTRA_CFLAGS=-g
obj-m := hello-kernel.o
hello-kernel-objs := hello.o


Now if I insmod my hello-kernel.ko file and then do a `cat
/sys/kernel/debug/kmemleak` I get an output:

unreferenced object 0xf8211000 (size 512):
 comm "insmod", pid 9602, jiffies 3666022 (age 1553.469s)
 hex dump (first 32 bytes):
   01 12 00 00 f2 10 00 00 01 12 00 00 fe 10 00 00  ................
   01 12 00 00 0c 11 00 00 01 12 00 00 1a 11 00 00  ................
 backtrace:
   [<c10b0001>] create_object+0x114/0x1db
   [<c148b4d0>] kmemleak_alloc+0x21/0x3f
   [<c10a43e9>] __vmalloc_node+0x83/0x90
   [<c10a44b9>] vmalloc+0x1c/0x1e
   [<f8208021>] 0xf8208021
   [<c1001226>] do_one_initcall+0x71/0x113
   [<c1056c48>] sys_init_module+0x1241/0x1430
   [<c100284c>] sysenter_do_call+0x12/0x22
   [<ffffffff>] 0xffffffff


I understand that the kmemleak has correctly detected the memory leak.
But why is the leak showing in insmod , instead of the actual function
name "hello_init". Is there a way we can get the exact location inside
the hello.c file printed instead of the generic "insmod" location  ?

If I do a `gdb hello-kernel.ko`, the symbols are properly resolved, so
I am sure the .ko file has symbols.

Any help will be appreciated. Thank you.

-- 
Sankar P
http://psankar.blogspot.com

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux