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: fence_chains_init: error unwind path leaks enable_sw_signaling reference
Date: Fri, 26 Jun 2026 14:33:54 +0200 [thread overview]
Message-ID: <414021d5-e6b2-4219-9ad9-2c342cbbc7f3@amd.com> (raw)
In-Reply-To: <20260626121825.35310-1-vulab@iscas.ac.cn>
On 6/26/26 14:18, WenTao Liang wrote:
> dma_fence_enable_sw_signaling acquires an extra reference on each chain
> fence. The error unwind loop calls dma_fence_put only once per
> chain/fence without first signaling the fence to trigger the callback
> that releases the signaling reference. This prevents the chain fence kref
> from reaching 0, permanently leaking the chain and its contained fence.
>
> Cc: stable@vger.kernel.org
> Fixes: dc2f7e67a28a ("dma-buf: Exercise dma-fence-chain under selftests")
Please drop that, this is a minor issue in a unit test and not anything which needs backporting.
> Signed-off-by: WenTao Liang <vulab@iscas.ac.cn>
> ---
> drivers/dma-buf/st-dma-fence-chain.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/dma-buf/st-dma-fence-chain.c b/drivers/dma-buf/st-dma-fence-chain.c
> index 821023dd34df..7dc18e294387 100644
> --- a/drivers/dma-buf/st-dma-fence-chain.c
> +++ b/drivers/dma-buf/st-dma-fence-chain.c
> @@ -152,7 +152,10 @@ static int fence_chains_init(struct fence_chains *fc, unsigned int count,
>
> unwind:
> for (i = 0; i < count; i++) {
> - dma_fence_put(fc->fences[i]);
> + if (fc->fences[i]) {
> + dma_fence_signal(fc->fences[i]);
> + dma_fence_put(fc->fences[i]);
> + }
The usual text book idiom for such cleanup cases is:
while (i--) {
dma_fence_signal(fc->fences[i]);
dma_fence_put(fc->chains[i]);
}
Additional to that we need a different error handling target for the case that the mock_chain() allocation fails (or just do another dma_fence_put there).
Regards,
Christian.
> dma_fence_put(fc->chains[i]);
> }
> kvfree(fc->fences);
next prev parent reply other threads:[~2026-06-26 12:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-26 12:18 WenTao Liang
2026-06-26 12:33 ` Christian König [this message]
2026-06-28 3:53 ` WenTao Liang
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=414021d5-e6b2-4219-9ad9-2c342cbbc7f3@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®