Hi,

I am starting to write linux kernel mode code. I am on Ubuntu 20.04. I have
written the following code

The line   DynPage[i]=0; //CRASH  causes a crash. Can you please guide on
the reason for the crash?

Thanks a lot in advance,
  Lloyd

#pragma GCC push_options
#pragma GCC optimize("O0")
void ClearMem(void)
{
unsigned int* DynPage=NULL;
unsigned int i=0;
DynPage=kmalloc(1024*16,GFP_KERNEL);
if(DynPage!=NULL)
{
DynPage[i]=0; //CRASH
}
kfree(DynPage);
DynPage=NULL;
return;
}
#pragma GCC pop_options
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

Reply via email to