title: Kmalloc doesn't work correctly
body: <p>I'm having some problems with this system call and probably with kmalloc.</p>
  
  <p>Well , basically I'm building a system call , and this system call and the kernel are compiled without a problem.
  But when I call my system call , the shell shows a lot of message and then the computer crash.</p>
  
  <p>I think the problem is with the <strong>kmalloc</strong> , because when I remove the <strong>kmalloc</strong> and other code that envolves the <strong>kmalloc</strong> the system call works perfectly.</p>
  
  <p><strong>For example: bloqueados = kmalloc(sizeof(struct bloqueio),GFP_ATOMIC);</strong></p>
  
  <p>Just to add :
  Maybe it's ocurring a deadlock , but I don't know accuratelly.</p>
  
  <p>Thank you.</p>
  
  <p>This is the code :</p>
  
  <pre><code>#include &lt;linux/linkage.h&gt;
  #include &lt;linux/io_block_unblock.h&gt;
  //#include &lt;linux/printk.h&gt;
  #include &lt;linux/kernel.h&gt;
  #include &lt;linux/unistd.h&gt;
  #include &lt;linux/stddef.h&gt;
  #include &lt;linux/slab.h&gt;
  #include &lt;linux/gfp.h&gt;
  #include &lt;linux/unistd.h&gt;
  #include &lt;linux/uaccess.h&gt;
  #include &lt;linux/fs.h&gt;
  #include &lt;linux/mount.h&gt;
  #include &lt;linux/genhd.h&gt;
  #include &lt;linux/device.h&gt;
  
  struct bloqueio *bloqueados;
  EXPORT_SYMBOLL(bloqueados);
  asmlinkage long sys_io_block(const char __user *particao, const char __user *arquivo){
      int id_inode;
      struct file *arq;
      char *part;
      struct bloqueio *tmp;
      arq  = filp_open(arquivo,O_CREAT, S_IRWXU);
      printk(KERN_EMERG "\nstruct file criado para o arquivo %s",arquivo);
      id_inode = arq-&gt;f_path.dentry-&gt;d_inode-&gt;i_ino;
      printk(KERN_EMERG "\nO inode do arquivo %s e  %d",arquivo, id_inode);
      //part = arq-&gt;f_path.mnt-&gt;mnt_sb-&gt;s_bdev-&gt;bd_part-&gt;__dev.init_name;
      //printk(KERN_EMERG "\nA particao a qual o arquivo se encontra e %s",part);
      if(bloqueados == NULL){
              bloqueados = kmalloc(sizeof(struct bloqueio),GFP_ATOMIC);//&lt;--------------
              if(!bloqueados){
                      printk(KERN_EMERG "\n Erro ao alocar memoria");
                      return 0;
              }
              bloqueados-&gt;inode = id_inode;
              bloqueados-&gt;tipo = 0;
              bloqueados-&gt;prox = NULL;
      }
      else
      {
              tmp = kmalloc(sizeof(struct bloqueio), GFP_ATOMIC);//&lt;--------------------
              if(!bloqueados){
                      printk(KERN_EMERG "\n Erro ao alocar memoria");
                      return 0;
              }
              tmp-&gt;inode = id_inode;
              tmp-&gt;tipo = 0;
              tmp-&gt;prox = bloqueados-&gt;prox;
              bloqueados-&gt;prox = tmp;
      }
      return 1;
  </code></pre>
  
  <p>}</p>
  
  <p><strong>Just to add , this is the struct bloqueio.</strong></p>
  
  <pre><code>extern int contem(const char *arquivo);
  
  struct bloqueio{
     int inode;
     int tipo;   // 0 -&gt; arquivo   1 -&gt; partição
     struct bloqueio *prox;
  };
  
   extern struct bloqueio *bloqueados;
  </code></pre>