Thread (4 messages) 4 messages, 2 authors, 2021-08-18

kmalloc - Crashing

From: Lloyd <hidden>
Date: 2021-08-18 11:34:00

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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help