Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux Kernel Programming: "Unable to handle kernel NULL pointer dereference"

I'm writing a Linux module and getting:

Unable to handle kernel NULL pointer dereference

What does it mean?

like image 823
Daniel Silveira Avatar asked Dec 04 '08 17:12

Daniel Silveira


2 Answers

Sounds like a pointer which currently has the NULL value (zero) is being dereferenced. Assign an address to the pointer before dereferencing it.

e.g.

int x = 5;
int * x_ptr = NULL;

x_ptr = &x; // this line may be missing in your code

*x_ptr += 5; //can't dereference x_ptr here if x_ptr is still NULL
like image 177
Nathan Avatar answered Sep 27 '22 17:09

Nathan


The kernel tries to read from address 0, which your kernel apparently treats specially (good thing!). As the kernel has no way to just kill itself like we know from user mode applications (those would have received a Segmentation Fault), this error is fatal. It will have probably panic'ed and displayed that message to you.


http://en.wikipedia.org/wiki/Null_pointer#The_null_pointer

like image 30
Johannes Schaub - litb Avatar answered Sep 27 '22 15:09

Johannes Schaub - litb