<div dir="ltr">Hi,<div><br></div><div>I am starting to write linux kernel mode code. I am on Ubuntu 20.04. I have written the following code </div><div><br></div><div>The line  <span style="color:rgb(212,212,212);font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback";font-size:14px;white-space:pre;background-color:rgb(30,30,30)">        </span><span style="font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback";font-size:14px;white-space:pre;background-color:rgb(30,30,30);color:rgb(156,220,254)">DynPage</span><span style="color:rgb(212,212,212);font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback";font-size:14px;white-space:pre;background-color:rgb(30,30,30)">[i]=</span><span style="font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback";font-size:14px;white-space:pre;background-color:rgb(30,30,30);color:rgb(181,206,168)">0</span><span style="color:rgb(212,212,212);font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback";font-size:14px;white-space:pre;background-color:rgb(30,30,30)">; //CRASH </span> causes a crash. Can you please guide on the reason for the crash?</div><div><br></div><div>Thanks a lot in advance,</div><div>  Lloyd </div><div><br></div><div><div style="color:rgb(212,212,212);background-color:rgb(30,30,30);font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback";font-size:14px;line-height:19px;white-space:pre"><div><span style="color:rgb(197,134,192)">#pragma</span><span style="color:rgb(86,156,214)"> </span><span style="color:rgb(156,220,254)">GCC</span><span style="color:rgb(86,156,214)"> </span><span style="color:rgb(156,220,254)">push_options</span></div><div><span style="color:rgb(197,134,192)">#pragma</span><span style="color:rgb(86,156,214)"> </span><span style="color:rgb(156,220,254)">GCC</span><span style="color:rgb(86,156,214)"> </span><span style="color:rgb(156,220,254)">optimize</span><span style="color:rgb(86,156,214)">(</span><span style="color:rgb(206,145,120)">"O0"</span><span style="color:rgb(86,156,214)">)</span></div><div><span style="color:rgb(86,156,214)">void</span> <span style="color:rgb(220,220,170)">ClearMem</span>(<span style="color:rgb(86,156,214)">void</span>)</div><div>{</div><div>    <span style="color:rgb(86,156,214)">unsigned</span> <span style="color:rgb(86,156,214)">int</span>* DynPage=<span style="color:rgb(86,156,214)">NULL</span>;</div><div>    <span style="color:rgb(86,156,214)">unsigned</span> <span style="color:rgb(86,156,214)">int</span> i=<span style="color:rgb(181,206,168)">0</span>;</div><div>    DynPage=<span style="color:rgb(220,220,170)">kmalloc</span>(<span style="color:rgb(181,206,168)">1024</span>*<span style="color:rgb(181,206,168)">16</span>,GFP_KERNEL); </div><div>    <span style="color:rgb(197,134,192)">if</span>(DynPage!=<span style="color:rgb(86,156,214)">NULL</span>)</div><div>    {</div><div>        <span style="color:rgb(156,220,254)">DynPage</span>[i]=<span style="color:rgb(181,206,168)">0</span>; //CRASH</div><div>    }</div><div>    <span style="color:rgb(220,220,170)">kfree</span>(DynPage);</div><div>    DynPage=<span style="color:rgb(86,156,214)">NULL</span>;</div><div>    <span style="color:rgb(197,134,192)">return</span>;</div><div>}</div><div><span style="color:rgb(197,134,192)">#pragma</span><span style="color:rgb(86,156,214)"> </span><span style="color:rgb(156,220,254)">GCC</span><span style="color:rgb(86,156,214)"> </span><span style="color:rgb(156,220,254)">pop_options</span></div></div></div><div></div></div>