Re: [PATCH v3] debugobjects: Fix inconsistent return handling and potential ERR_PTR dereference
From: Thomas Gleixner
Date: Sat Nov 15 2025 - 18:18:20 EST
On Fri, Nov 14 2025 at 09:56, Haotian Zhang wrote:
> The lookup_object_or_alloc() function can return NULL on memory
> allocation failure, while returning an error pointer for other errors.
> Call sites such as __debug_object_init() and debug_object_activate()
> only check for errors using IS_ERR(), which does not evaluate to true
> for a NULL pointer. This can lead to a NULL pointer dereference if
> memory allocation fails.
Nice fairy tale. Let's look at the facts.
__debug_object_init():
obj = lookup_object_or_alloc(addr, db, descr, onstack, false);
if (unlikely(!obj)) {
....
Does not use IS_ERR() at all and _is_ completely correct because
lookup_object_or_alloc() can only return NULL or a valid object but
never an error pointer because the 'alloc_ifstatic' argument is NULL.
debug_object_activate():
obj = lookup_object_or_alloc(addr, db, descr, false, true);
if (unlikely(!obj)) {
....
} else if (likely(!IS_ERR(obj))) {
....
handles both the NULL pointer and the error pointer case correctly.
I have no idea which code you were analyzing or which tool halluzinated
about it.
> Fixes: 63a759694eed ("debugobject: Prevent init race with static objects")
There is nothing broken, so this fixes nothing.
Thanks,
tglx