In drm_gem_plane_helper_prepare_fb(), when both "new" (the plane's GEM
singleton fence) and "fence" (explicit or previous plane's) exist, they
are wrapped in a freshly allocated chain. If dma_fence_chain_alloc()
fails, the error path runs before dma_fence_chain_init() adopts "new",
and error: only puts "fence" - leaking one fence reference per failure.
Put "new" in the allocation-failure branch.
Found by static analysis.
Fixes: 1ea28bc5542d ("drm: handle kernel fences in
drm_gem_plane_helper_prepare_fb v2")
Signed-off-by: Chengyu Liu <[email protected]>
---
v3: regenerate with git format-patch so the hunk header carries the
function context. No code change.
v2: add the Fixes trailer for 1ea28bc5542d
https://lore.kernel.org/dri-devel/[email protected]/
v1:
https://lore.kernel.org/dri-devel/[email protected]/
Build-tested on x86_64: drm_gem_atomic_helper.o compiles clean. Fix
written with AI assistance.
drivers/gpu/drm/drm_gem_atomic_helper.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/gpu/drm/drm_gem_atomic_helper.c
b/drivers/gpu/drm/drm_gem_atomic_helper.c
index dd9efa7e3216..5d5bc0d1495c 100644
--- a/drivers/gpu/drm/drm_gem_atomic_helper.c
+++ b/drivers/gpu/drm/drm_gem_atomic_helper.c
@@ -154,6 +154,7 @@ int drm_gem_plane_helper_prepare_fb(struct drm_plane *plane,
struct dma_fence_chain *chain = dma_fence_chain_alloc();
if (!chain) {
+ dma_fence_put(new);
ret = -ENOMEM;
goto error;
}
--
2.25.1