Can we use cppcheck for detection of kernel memory leaks (memory created by kzalloc or kmalloc)? if yes, please provide some example how we can use it.
I have tried writing .cfg file ex: mem.cfg
it has content file name mem.cfg
<?xml version="1.0"?>
<def format="1">
<memory>
<dealloc>kfree</dealloc>
<alloc init="false">kmalloc</alloc>
<alloc init="true">kzalloc</alloc>
</memory>
</def>
while running cppcheck command I have used command like below.
cppcheck --library=mem.cfg fs/sample/my_module.c
Here my_module.c is kernel module it has implementation of kernel memory creation with kernel api ex:kzalloc .
I have not used kernel memory free api. it should give kernel memory leak, but cppcheck its not reported.