0

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 ?

Ruocco
  • 575
  • 2
  • 12
  • 26
  • That is not an issue with kmalloc. The problem is in how and where you use it. Can you specify? – Alex Hoppus Jun 27 '18 at 08:01
  • @AlexHoppus it does not look like kmalloc issue. I have two structures. The one I allocated struct st_fetch_point *first_fetch_point & another one struct st_fetch_point *start_fetch_point. Both of them are of the same category. After allocating memory I am trying to do the following: tp->mptcp->current_fetch_point = first_fetch_point ; // tp->mptcp->current_fetch_point = NULL before this point and it looks like kernel is freezing in this point. Can you suggest what I am doing wrong in this point. – Imran Khan Jun 28 '18 at 16:47
  • @AlexHoppus can you check this query https://stackoverflow.com/questions/51160282/structure-pointer-assignment-causes-kernel-freeze – Imran Khan Jul 05 '18 at 18:36

0 Answers0