Re: Check for kmalloc retrun values

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

 



On Tue, 2006-01-17 at 12:56 +0100, Hendrik Post wrote:
> Hi!
> 
> I found several places in the kernel source code where kmalloc is called 
> without any check if the return value is null. Is this a serious matter, 
> e.g. should such code be fixed?

sometimes

> 
> My intuition is that otherwise this could lead to code defreferencing a 
> null pointer, though it is not likely that kmalloc fails...
> 
> Is it reasonable to enforce such checks for errors for all modules?

for modules, yes.

There are a set of known cases which ONLY happen during really early
boot, and for which no reasonable recovery is possible. (eg if you run
out of memory before even having started userspace, your system isn't
going to be any good anyway, and during that phase of booting you NEED
to have certain things. Like a root filesystem, or like things internal
to the VM). Those are known cases and ok as is.

But in "drivers" which can be a module, it generally is a bug that wants
fixing yes.



--
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