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

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.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D37367
This commit is contained in:
Jean-Sébastien Pédron 2022-11-11 21:03:25 +01:00
parent 86a1c5d129
commit 208d02fd5d
No known key found for this signature in database
GPG Key ID: 39E99761A5FD94CC

View File

@ -90,6 +90,8 @@ struct linux_kmem_cache;
/* drm-kmod 5.4 compat */
#define kfree_async(ptr) kfree(ptr);
#define ZERO_OR_NULL_PTR(x) ((x) == NULL)
static inline gfp_t
linux_check_m_flags(gfp_t flags)
{