I am trying to allocate memory in the Linux kernel using kmalloc. I have a structure designed as below:
struct st_fetch_point {
struct sk_buff *end_pkt ;
struct sk_buff *start_pkt ;
struct sk_buff *current_pkt ;
struct st_fetch_point *next_fortp ;
struct st_fetch_point *next_consec ;
};
I have created a new structure of the type st_fetch_point and trying to allocate memory & assign values to the member pointers in below fashion:
struct st_fetch_point *first_fetch_point;
first_fetch_point = kmalloc((sizeof(struct st_fetch_point)), GFP_ATOMIC);
if (!first_fetch_point)
return -ENOMEM;
skb = tcp_send_head(meta_sk);
first_fetch_point->start_pkt = skb;
first_fetch_point->current_pkt = skb;
first_fetch_point->end_pkt = NULL;
first_fetch_point->next_fortp = NULL;
first_fetch_point->next_consec = NULL;
But it looks like the kernel is freezing each time it comes to kmalloc() execution line. I am working on ubuntu 14.04 and really in a fix. I checked syslog and kernlog files and did not find any unusual messages related to the freezing. Is this any issue with the kmalloc() allocation method ?