HomeFreeBSD

LinuxKPI: add kmalloc_obj[s], kzalloc_obj[s], and kzalloc_flex

Description

LinuxKPI: add kmalloc_obj[s], kzalloc_obj[s], and kzalloc_flex

Drivers in Linux v7.0 seem to have changed to the new allocation
macros using a sweep. Add the ones I encountered with wireless
drivers so far. They all take an optional argument for a gfp_t,
which default_gfp() deals with.

The plural version "objs" takes an extra nitems argument in addition
to the size. We use size_mul() to possibly detect overflows.

The "flex" version uses an extra variable to track the variable sized
array allocations and if supported by the compiler will use
__builtin_counted_by_ref() to properly track bounds.

Sponsored by: The FreeBSD Foundation
Reviewed by: dumbbell
Differential Revision: https://reviews.freebsd.org/D56395

(cherry picked from commit c72ac6af086962d236f4712761abacac0c62b48e)

Details

Provenance
bzAuthored on Apr 14 2026, 3:13 PM
Reviewer
dumbbell
Differential Revision
D56395: LinuxKPI: add kmalloc_obj[s], kzalloc_obj[s], and kzalloc_flex
Parents
rG3548ab72de58: LinuxKPI: sync overflow.h from Linux v7.0
Branches
Unknown
Tags
Unknown