git: 0ce099e9e391 - stable/13 - linuxkpi: Define `ZERO_OR_NULL_PTR()` in <linux/slab.h>
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 24 Jan 2023 08:54:09 UTC
The branch stable/13 has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=0ce099e9e39154a53689fcd8e3cc06d8b67a2088 commit 0ce099e9e39154a53689fcd8e3cc06d8b67a2088 Author: Jean-Sébastien Pédron <dumbbell@FreeBSD.org> AuthorDate: 2022-11-11 20:03:25 +0000 Commit: Emmanuel Vadot <manu@FreeBSD.org> CommitDate: 2023-01-24 09:08:01 +0000 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 (cherry picked from commit 208d02fd5d165389aed0c2b60519cb6b0f5b89f9) --- sys/compat/linuxkpi/common/include/linux/slab.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/slab.h b/sys/compat/linuxkpi/common/include/linux/slab.h index d76b376c01a2..131c7c417649 100644 --- a/sys/compat/linuxkpi/common/include/linux/slab.h +++ b/sys/compat/linuxkpi/common/include/linux/slab.h @@ -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) {