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));
Indeed, you should use kmalloc and friends, check the linux kernel for examples. e.g.: http://lxr.linux.no/linux+v3.0/drivers/infiniband/hw/mthca/mthca_provider.c#L1033