Re: [patch 03/25] debugobjects: Dont destroy kmem cache in init()

From: Leizhen (ThunderTown)
Date: Thu Oct 10 2024 - 09:32:06 EST




On 2024/10/10 19:46, Thomas Gleixner wrote:
> On Thu, Oct 10 2024 at 10:14, Leizhen wrote:
>> On 2024/10/8 0:49, Thomas Gleixner wrote:
>>> - if (!obj_cache || debug_objects_replace_static_objects()) {
>>> + if (!cache || !debug_objects_replace_static_objects(cache)) {
>>> debug_objects_enabled = 0;
>>> - kmem_cache_destroy(obj_cache);
>>
>> kmem_cache_destroy(cache) should be kept, or move it into debug_objects_replace_static_objects()
>> and place it above 'return false'.
>
> At that point it can't be destroyed. See the backtrace.
>
> So we just give the objects back and leak the kmem_cache.

Oh, sorry, I didn't figure it out before, but now I do.
But shouldn't we add kmemleak_ignore(cache) ?

>
> Thanks,
>
> tglx
>
> .
>

--
Regards,
Zhen Lei