malloc in kernel

后端 未结 6 2059
南旧
南旧 2020-12-20 13:10

When I try to use malloc in a kernel module I get an error message from the compiler. My code:

res=(ListNode*)malloc(sizeof(ListNode));
<         


        
6条回答
  •  执笔经年
    2020-12-20 13:19

    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

提交回复
热议问题