The kmem_cache_alloc() call in active_instance() can fail under
memory pressure, returning NULL. The existing code handles this by
branching to the 'out' label, which stores the NULL pointer in
ref->cache.
However, the final return statement unconditionally dereferences
the base field, which would be invalid if node is NULL. Add an
explicit NULL check to safely propagate allocation failures to
the caller.
Fixes: 12c255b5dad1 ("drm/i915: Provide an i915_active.acquire callback")
Signed-off-by: Kaushlendra Kumar <[email protected]>
---
drivers/gpu/drm/i915/i915_active.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/i915/i915_active.c
b/drivers/gpu/drm/i915/i915_active.c
index 6b0c1162505a..1ebb3c425e67 100644
--- a/drivers/gpu/drm/i915/i915_active.c
+++ b/drivers/gpu/drm/i915/i915_active.c
@@ -331,7 +331,7 @@ active_instance(struct i915_active *ref, u64 idx)
WRITE_ONCE(ref->cache, node);
spin_unlock_irq(&ref->tree_lock);
- return &node->base;
+ return node ? &node->base : NULL;
}
void __i915_active_init(struct i915_active *ref,
--
2.34.1