mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: WenTao Liang <vulab@iscas.ac.cn>, sumit.semwal@linaro.org
Cc: linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org,
	linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH] fix: dma-buf: unwrap_merge_complex: dma_fence_get_stub reference leaked on all paths
Date: Fri, 26 Jun 2026 14:47:47 +0200	[thread overview]
Message-ID: <5180c887-c879-440f-a58b-1cad96b7abb1@amd.com> (raw)
In-Reply-To: <20260626122836.35856-1-vulab@iscas.ac.cn>

On 6/26/26 14:28, WenTao Liang wrote:
> dma_fence_get_stub() acquires an extra reference on the global stub
>   fence, but this reference is never released on any execution path. The
>   stub fence is filtered out inside dma_fence_unwrap_merge (already
>   signaled), so the extra reference is never consumed. Both success and
>   error paths fail to call dma_fence_put on the stub.
> 
> Cc: stable@vger.kernel.org
> Fixes: 245a4a7b531c ("dma-buf: generalize dma_fence unwrap & merging v3")

Just drop that, the stub fence is a global dummy and leaking reference to it is harmless.

But just in case somebody uses this code as blueprint for this own implementation we should probably clean it up.

> Signed-off-by: WenTao Liang <vulab@iscas.ac.cn>

Reviewed-by: Christian König <christian.koenig@amd.com>

> ---
>  drivers/dma-buf/st-dma-fence-unwrap.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/dma-buf/st-dma-fence-unwrap.c b/drivers/dma-buf/st-dma-fence-unwrap.c
> index 72ca632e3981..b9ed85570211 100644
> --- a/drivers/dma-buf/st-dma-fence-unwrap.c
> +++ b/drivers/dma-buf/st-dma-fence-unwrap.c
> @@ -483,7 +483,7 @@ static int unwrap_merge_order(void *arg)
>  
>  static int unwrap_merge_complex(void *arg)
>  {
> -	struct dma_fence *fence, *f1, *f2, *f3, *f4, *f5;
> +	struct dma_fence *fence, *f1, *f2, *f3, *f4, *f5, *stub;
>  	struct dma_fence_unwrap iter;
>  	int err = -ENOMEM;
>  
> @@ -508,10 +508,11 @@ static int unwrap_merge_complex(void *arg)
>  	if (!f4)
>  		goto error_put_f3;
>  
> +	stub = dma_fence_get_stub();
>  	/* Signaled fences should be filtered, the two arrays merged. */
> -	f5 = dma_fence_unwrap_merge(f3, f4, dma_fence_get_stub());
> +	f5 = dma_fence_unwrap_merge(f3, f4, stub);
>  	if (!f5)
> -		goto error_put_f4;
> +		goto error_put_stub;
>  
>  	err = 0;
>  	dma_fence_unwrap_for_each(fence, &iter, f5) {
> @@ -532,8 +533,10 @@ static int unwrap_merge_complex(void *arg)
>  		err = -EINVAL;
>  	}
>  
> +	dma_fence_put(stub);
>  	dma_fence_put(f5);
> -error_put_f4:
> +error_put_stub:
> +	dma_fence_put(stub);
>  	dma_fence_put(f4);
>  error_put_f3:
>  	dma_fence_put(f3);


      reply	other threads:[~2026-06-26 12:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-26 12:28 WenTao Liang
2026-06-26 12:47 ` Christian König [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5180c887-c879-440f-a58b-1cad96b7abb1@amd.com \
    --to=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=sumit.semwal@linaro.org \
    --cc=vulab@iscas.ac.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®