kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* kmalloc - Crashing
@ 2021-08-18 11:33 Lloyd
  2021-08-18 12:08 ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Lloyd @ 2021-08-18 11:33 UTC (permalink / raw)
  To: kernelnewbies


[-- Attachment #1.1: Type: text/plain, Size: 509 bytes --]

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

[-- Attachment #1.2: Type: text/html, Size: 3695 bytes --]

[-- Attachment #2: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-08-18 12:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-18 11:33 kmalloc - Crashing Lloyd
2021-08-18 12:08 ` Greg KH
2021-08-18 12:37   ` Lloyd
2021-08-18 12:45     ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).