Re: [PATCH 16/20] mm/slab: move kmalloc_slab() to mm/slab.h

From: Kees Cook
Date: Mon Nov 13 2023 - 23:07:35 EST


On Mon, Nov 13, 2023 at 08:13:57PM +0100, Vlastimil Babka wrote:
> In preparation for the next patch, move the kmalloc_slab() function to
> the header, as it will have callers from two files, and make it inline.
> To avoid unnecessary bloat, remove all size checks/warnings from
> kmalloc_slab() as they just duplicate those in callers, especially after
> recent changes to kmalloc_size_roundup(). We just need to adjust handling
> of zero size in __do_kmalloc_node(). Also we can stop handling NULL
> result from kmalloc_slab() there as that now cannot happen (unless
> called too early during boot).
>
> The size_index array becomes visible so rename it to a more specific
> kmalloc_size_index.
>
> Signed-off-by: Vlastimil Babka <vbabka@xxxxxxx>

Yeah, removing the redundant size checks does make this nicer to look at. :)

Reviewed-by: Kees Cook <keescook@xxxxxxxxxxxx>

--
Kees Cook