Re: [PATCH 1/2] debugobjects: Fix NULL pointer dereference in kmem_alloc_batch()

From: Sang-Heon Jeon

Date: Mon Nov 09 2026 - 00:15:30 EST


Hi Andrew,

2026년 11월 9일 (월) 오후 1:56, Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>님이 작성:
>
> On Mon, 9 Nov 2026 13:12:10 +0900 Sang-Heon Jeon <ekffu200098@xxxxxxxxx> wrote:
>
> > During boot, debug_objects_replace_static_objects() calls
> > kmem_alloc_batch() while obj_cache is still NULL.
> >
> > If kmem_cache_zalloc() fails, kmem_alloc_batch() tries to free the
> > allocated objects with free_object_list(). But free_object_list()
> > always calls kmem_cache_free() with obj_cache, which causes a NULL
> > pointer dereference.
> >
> > So use the cache passed to kmem_alloc_batch() instead.
>
> Thanks.
>
> We conventionally assume that memory allocations in __init code cannot
> fail. Because if they do fail, something has already gone horribly
> wrong with the kernel and it simply isn't viable. If an unchecked
> allocation results in an oops then that's fine - it was inevitable
> anyway.
>

Right, I only can reproduce it with fault-injection. I just sent this
patch because __init debug_objects_replace_static_objects() already
frees some objects on allocation failure. But again, I totally agree
with your point, so I'm fine with dropping this patch.

Best regards,
Sang-Heon Jeon