Re: How is NULL pointer dereference handled inside kernel?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Yes you are right. From <linux/stddef.h>,

#undef NULL
#if defined(__cplusplus)
#define NULL 0
#else
#define NULL ((void *)0)
#endif

Thankyou,

--
Kishore A K


On Wed, 17 Nov 2004 22:27:34 -0700 (MST), jnf <lists@xxxxxxxxxxxxxxxxxx> wrote:
> Actually the inverse is true- or at least AFAIK, I know for a fact however
> NULL in C is (void *)0, and i _think_ in c++ its just 0.
> 
> --
> 
> There are only two choices in life. You either conform the truth to your desire,
> or you conform your desire to the truth. Which choice are you making?
> On Thu, 18 Nov 2004, Kishore A K wrote:
> 
> > Date: Thu, 18 Nov 2004 10:44:44 +0530
> > From: Kishore A K <kishoreak@xxxxxxxxx>
> > To: Mandeep Sandhu <mandeep_sandhu@xxxxxxxxxxx>
> > Cc: kernelnewbies <kernelnewbies@xxxxxxxxxxxx>
> > Subject: Re: How is NULL pointer dereference handled inside kernel?
> 
> 
> >
> > NULL == 0 in all currently known architectures while coding in
> > C. And I think NULL == (void *)0 if you code in C++. Infact in
> > many places in the linux kernel source NULL & 0 have been used
> > interchangably.
> >
> > --
> > Kishore A K
> >
> > "Dream as if you'll live forever; Live as if you'll die today."
> >
> >
> > On Thu, 18 Nov 2004 10:27:49 +0530, Mandeep Sandhu
> > <mandeep_sandhu@xxxxxxxxxxx> wrote:
> > > Hi all,
> > >
> > > a basic question. How does the kernel handle NULL pointer
> > > dereferencing inside kernel space. Supposing I initialise a pointer
> > > to NULL (i.e 0), and derefernce it then why do I get an oops?
> > > Is 0 not a valid address? Also I've heard that the value of NULL can
> > > change from processor to processor (I think on PowerPC 0 is a valid
> > > address).
> > >
> > > TIA,
> > > -mandeep
> > >
> > > --
> > > Kernelnewbies: Help each other learn about the Linux kernel.
> > > Archive:       http://mail.nl.linux.org/kernelnewbies/
> > > FAQ:           http://kernelnewbies.org/faq/
> > >
> > >
> >
> > --
> 
> 
> > Kernelnewbies: Help each other learn about the Linux kernel.
> > Archive:       http://mail.nl.linux.org/kernelnewbies/
> > FAQ:           http://kernelnewbies.org/faq/
> >
> >
>

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux