* [PATCH] drm/gem-atomic-helper: fix fence leak on dma_fence_chain_alloc() failure
@ 2026-11-07 16:53 Chengyu Liu
2026-11-09 9:50 ` sashiko-bot
2026-11-13 14:04 ` Ville Syrjälä
0 siblings, 2 replies; 5+ messages in thread
From: Chengyu Liu @ 2026-11-07 16:53 UTC (permalink / raw)
To: dri-devel; +Cc: maarten.lankhorst, mripard, tzimmermann, Chengyu Liu
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.
Signed-off-by: Chengyu Liu <lui2012qwq@gmail.com>
---
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 abef865c5f2c..1e484f26ab31 100644
--- a/drivers/gpu/drm/drm_gem_atomic_helper.c
+++ b/drivers/gpu/drm/drm_gem_atomic_helper.c
@@ -153,6 +153,7 @@
if (new && fence) {
struct dma_fence_chain *chain = dma_fence_chain_alloc();
if (!chain) {
+ dma_fence_put(new);
ret = -ENOMEM;
goto error;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] drm/gem-atomic-helper: fix fence leak on dma_fence_chain_alloc() failure
2026-11-07 16:53 [PATCH] drm/gem-atomic-helper: fix fence leak on dma_fence_chain_alloc() failure Chengyu Liu
@ 2026-11-09 9:50 ` sashiko-bot
2026-11-12 15:52 ` Chengyu Liu
2026-11-13 14:04 ` Ville Syrjälä
1 sibling, 1 reply; 5+ messages in thread
From: sashiko-bot @ 2026-11-09 9:50 UTC (permalink / raw)
To: Chengyu Liu, dri-devel
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] drm/gem-atomic-helper: missing Fixes trailer for commit
1ea28bc5542d
--
commit b6d9ff23bfcc702d784107d5026972257646c1fc
Author: Chengyu Liu <lui2012qwq@gmail.com>
> drm/gem-atomic-helper: fix fence leak on dma_fence_chain_alloc() failure
>
> 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.
>
> Signed-off-by: Chengyu Liu <lui2012qwq@gmail.com>
[Severity: Low]
Should this commit include a Fixes: tag for the commit that introduced the
leak:
Fixes: 1ea28bc5542d ("drm: handle kernel fences in drm_gem_plane_helper_prepare_fb v2")
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261107165303.13508-1-lui2012qwq@gmail.com?part=1
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] drm/gem-atomic-helper: fix fence leak on dma_fence_chain_alloc() failure
2026-11-09 9:50 ` sashiko-bot
@ 2026-11-12 15:52 ` Chengyu Liu
0 siblings, 0 replies; 5+ messages in thread
From: Chengyu Liu @ 2026-11-12 15:52 UTC (permalink / raw)
To: sashiko-reviews; +Cc: dri-devel
On Mon, Nov 9, 2026 at 5:50 PM <sashiko-bot@kernel.org> wrote:
> [Severity: Low]
> Should this commit include a Fixes: tag for the commit that introduced the
> leak:
>
> Fixes: 1ea28bc5542d ("drm: handle kernel fences in drm_gem_plane_helper_prepare_fb v2")
Thanks, v2 will include the fix tag.
On Mon, Nov 9, 2026 at 5:50 PM <sashiko-bot@kernel.org> wrote:
>
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue to consider:
> - [Low] drm/gem-atomic-helper: missing Fixes trailer for commit
> 1ea28bc5542d
> --
>
> commit b6d9ff23bfcc702d784107d5026972257646c1fc
> Author: Chengyu Liu <lui2012qwq@gmail.com>
>
> > drm/gem-atomic-helper: fix fence leak on dma_fence_chain_alloc() failure
> >
> > 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.
> >
> > Signed-off-by: Chengyu Liu <lui2012qwq@gmail.com>
>
> [Severity: Low]
> Should this commit include a Fixes: tag for the commit that introduced the
> leak:
>
> Fixes: 1ea28bc5542d ("drm: handle kernel fences in drm_gem_plane_helper_prepare_fb v2")
>
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/20261107165303.13508-1-lui2012qwq@gmail.com?part=1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] drm/gem-atomic-helper: fix fence leak on dma_fence_chain_alloc() failure
2026-11-07 16:53 [PATCH] drm/gem-atomic-helper: fix fence leak on dma_fence_chain_alloc() failure Chengyu Liu
2026-11-09 9:50 ` sashiko-bot
@ 2026-11-13 14:04 ` Ville Syrjälä
2026-11-13 15:55 ` Chengyu Liu
1 sibling, 1 reply; 5+ messages in thread
From: Ville Syrjälä @ 2026-11-13 14:04 UTC (permalink / raw)
To: Chengyu Liu; +Cc: dri-devel, maarten.lankhorst, mripard, tzimmermann
On Sun, Nov 08, 2026 at 12:53:03AM +0800, Chengyu Liu wrote:
> 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.
>
> Signed-off-by: Chengyu Liu <lui2012qwq@gmail.com>
> ---
> 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 abef865c5f2c..1e484f26ab31 100644
> --- a/drivers/gpu/drm/drm_gem_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_gem_atomic_helper.c
> @@ -153,6 +153,7 @@
^
Why are we missing the context here? Is this some git misconfiguration
or bug?
> if (new && fence) {
> struct dma_fence_chain *chain = dma_fence_chain_alloc();
>
> if (!chain) {
> + dma_fence_put(new);
> ret = -ENOMEM;
> goto error;
> }
> --
> 2.25.1
--
Ville Syrjälä
Intel
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] drm/gem-atomic-helper: fix fence leak on dma_fence_chain_alloc() failure
2026-11-13 14:04 ` Ville Syrjälä
@ 2026-11-13 15:55 ` Chengyu Liu
0 siblings, 0 replies; 5+ messages in thread
From: Chengyu Liu @ 2026-11-13 15:55 UTC (permalink / raw)
To: Ville Syrjälä
Cc: dri-devel, maarten.lankhorst, mripard, tzimmermann
On Fri, Nov 13, 2026 at 10:04 PM Ville Syrjälä
<ville.syrjala@linux.intel.com> wrote:
> > diff --git a/drivers/gpu/drm/drm_gem_atomic_helper.c b/drivers/gpu/drm/drm_gem_atomic_helper.c
> > index abef865c5f2c..1e484f26ab31 100644
> > --- a/drivers/gpu/drm/drm_gem_atomic_helper.c
> > +++ b/drivers/gpu/drm/drm_gem_atomic_helper.c
> > @@ -153,6 +153,7 @@
> ^
>
> Why are we missing the context here? Is this some git misconfiguration
> or bug?
My mistake, not a Git problem.
I assembled the patch outside the kernel Git tree instead of
generating it from a commit with git format-patch, so the hunk headers
were missing the function context. Since v2 was based on v1, it
inherited the same issue.
git apply and checkpatch.pl accept the patch without this context,
which is how I missed it.
v3 contains the same fix, regenerated from a commit in the kernel tree
using git format-patch. The hunk headers now include the proper
function context.
Sorry for the noise.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-11-13 15:56 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-07 16:53 [PATCH] drm/gem-atomic-helper: fix fence leak on dma_fence_chain_alloc() failure Chengyu Liu
2026-11-09 9:50 ` sashiko-bot
2026-11-12 15:52 ` Chengyu Liu
2026-11-13 14:04 ` Ville Syrjälä
2026-11-13 15:55 ` Chengyu Liu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.