When I try to use malloc in a kernel module I get an error message from the compiler. My code:
malloc
res=(ListNode*)malloc(sizeof(ListNode)); <
res=(ListNode*)malloc(sizeof(ListNode));
use kmalloc/kfree. You may grep malloc in kernel source code.