Page MenuHomeFreeBSD

linuxkpi: Define `ZERO_OR_NULL_PTR()` in <linux/slab.h>
ClosedPublic

Authored by dumbbell on Nov 11 2022, 6:30 PM.
Tags
None
Referenced Files
F153753642: D37367.diff
Thu, Apr 23, 11:01 AM
Unknown Object (File)
Tue, Apr 21, 7:42 AM
Unknown Object (File)
Mon, Apr 20, 6:10 PM
Unknown Object (File)
Mon, Apr 20, 4:32 AM
Unknown Object (File)
Mon, Apr 20, 3:19 AM
Unknown Object (File)
Mon, Apr 6, 6:37 AM
Unknown Object (File)
Thu, Mar 26, 9:37 AM
Unknown Object (File)
Wed, Mar 25, 10:45 PM

Details

Summary

On Linux, the kmalloc() family of functions returns a special value if the size of the allocation is zero. This macro verifies if the pointer is NULL (the allocation failed) or the size is 0 (the allocation was not performed AFAIU). This special value can be passed to kfree().

On FreeBSD, our malloc(9) functions don't return a special value for 0-size allocations. Therefore we can simply compare the result against NULL.

This change is a requirement to update our DRM drivers to Linux 5.12.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable