- Subject: how to use the memory allocated in kernel?
- From: 夏业添 <summerxyt@xxxxxxxxx>
- Date: Wed, 18 Apr 2012 15:44:19 +0800
Hi everyone,
there are some functions can alloc memory in kernel, but it seems that I cannot use it directly. Here is my code:
static int mytest_vm(){
struct vm_struct *v_start;
v_start=alloc_vm_area(PAGE_SIZE,NULL); //the kernel api has changed, I don't understand why there is a second parameter
if(v_start==NULL){
printk("cannot alloc page\n");
return -1;
}
sprintf((char *)v_start->addr,"this is a test.\n");
printk("after sprintk:%s",(char *)v_start->addr);
free_vm_area(v_start);
return 0;
}
module_init(mytest_vm);
but it just got a kernel Oops. Can anyone explain this to me? Thanks very much!
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
[Newbies FAQ]
[Linux Kernel Development]
[IETF Annouce]
[Git]
[Networking]
[Security]
[Bugtraq]
[Photo]
[Yosemite]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux Networking]
[Linux RAID]
[Linux SCSI]
[Linux ACPI]