tech-kern archive

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

Re: kmem_alloc(0, f)



> Date: Tue, 1 Aug 2017 06:23:28 -0000 (UTC)
> From: mlelstv%serpens.de@localhost (Michael van Elst)
> 
> martin%duskware.de@localhost (Martin Husemann) writes:
> 
> >An empty array still is 99% of the times a driver bug and simply caught
> >when first trying the driver. All other call sides can simply avoid the
> >allocation and use a NULL pointer instead.
> 
> Aren't zero sized allocations a must for Linux kernel shim compatibility?
> If I remember correctly the major user was the radeon DRM code.

Linux code for which we provide source compatibility uses Linux
kmalloc, which allows zero-size allocations unlike kmem_alloc.

(kmalloc uses malloc(9) currently; if adapted to use kmem(9), it would
have to use nonzero-sized allocations anyway to store the size, since
Linux kfree doesn't pass the size.)

Anywhere we have adapted the code to use kmem_alloc, e.g. for a large
chunk of NetBSD-specific code, has the same issue as any other driver:
need to prove that the inputs can't be zero.


Home | Main Index | Thread Index | Old Index