title: Kernel module linked list strange behaviour
body: <p>I am creating a linked list in kernel module ; It has no problem with adding the first record , in init module i am initializing the map also with create map function ;</p>
  
  <pre><code>typedef struct IP4SYN{    
      unsigned int KaynakIP;
      u_int16_t KaynakPort;
      u_int16_t HedefPort;
  } IP4SYN;
  
  typedef struct IP4Map{
      unsigned int HedefIP;
      IP4SYN * a;
      size_t s;
      size_t n;
  } IP4Map;
  
  typedef struct Sessions{
      IP4Map * a;
      size_t s;
      size_t n;
  } Sessions;
  static size_t blocksize = (1024*102);
  
  Sessions * Session_Map;
  
  static unsigned int get_tsval(void){    
      return (unsigned int)(ktime_to_ns(ktime_get())&gt;&gt;10);
  }
  Sessions * CreateMap(size_t initial){
      Sessions * pMap = (Sessions *)vmalloc(sizeof(Sessions));
      if (initial &gt; 0 &amp;&amp; blocksize != initial) {
          blocksize = initial;
      }
      pMap-&gt;a = (IP4Map *)vmalloc(sizeof(IP4Map)*blocksize);
      memset(pMap-&gt;a, 0, sizeof(IP4Map)*blocksize);
      pMap-&gt;s = blocksize;  
      pMap-&gt;n = 0;  
  
      pMap-&gt;a-&gt;a=(IP4SYN *)vmalloc(sizeof(IP4SYN)*blocksize);
      memset(pMap-&gt;a-&gt;a, 0, sizeof(IP4SYN)*blocksize);
      pMap-&gt;a-&gt;s = blocksize;  
      pMap-&gt;a-&gt;n = 0;  
      return pMap;   
  }
  size_t HedefIPKayitNo(unsigned int HedefIP){
      size_t beg = 0; 
      size_t end = Session_Map-&gt;n;
      for (beg; beg &lt; end; beg) {
          IP4Map map = Session_Map-&gt;a[beg];
          if(map.HedefIP==HedefIP){
              return beg;
              break;
          }
      }
      return beg;
  }   
  size_t YeniHedefIP(unsigned int HedefIP,size_t index){
      Session_Map-&gt;a[index].HedefIP = HedefIP;
      Session_Map-&gt;n++;
  }
  </code></pre>
  
  <p>I want to check if ip exist in listed and if not listed i want to add it to the list. But strangely it causing lack of kernel on 2nd try . 1st add-up is working perfect. what should be the issue ?</p>
  
  <pre><code>size_t IP_Index = HedefIPKayitNo(hedef_ip);
          if(IP_Index == Session_Map-&gt;n ){
                  YeniHedefIP(hedef_ip,(IP_Index));
  
  }
  </code></pre>