From: sashiko-bot@kernel.org
To: "WenTao Liang" <vulab@iscas.ac.cn>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] fix: dma-buf: unwrap_merge_complex: dma_fence_get_stub reference leaked on all paths
Date: Fri, 26 Jun 2026 12:34:55 +0000 [thread overview]
Message-ID: <20260626123455.BE3321F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260626122836.35856-1-vulab@iscas.ac.cn>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Double free / refcount underflow on the global static `dma_fence_stub` in `unwrap_merge_complex()`.
--
commit 361d06ca0291c480e1aafadac1b89e324d9431ab
Author: WenTao Liang <vulab@iscas.ac.cn>
fix: dma-buf: unwrap_merge_complex: dma_fence_get_stub reference leaked on all paths
This commit fixes a reference leak on the global stub fence in
unwrap_merge_complex() by adding dma_fence_put() calls to the success and
error paths.
> diff --git a/drivers/dma-buf/st-dma-fence-unwrap.c b/drivers/dma-buf/st-dma-fence-unwrap.c
> --- a/drivers/dma-buf/st-dma-fence-unwrap.c
> +++ b/drivers/dma-buf/st-dma-fence-unwrap.c
[ ... ]
> @@ -530,8 +531,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);
[Severity: Medium]
Does this cause a double-put of the stub on the success path?
When unwrap_merge_complex() successfully completes, it appears execution
will call dma_fence_put(stub) just before putting f5, and then fall right
through into the error_put_stub label where it calls dma_fence_put(stub) a
second time.
Since dma_fence_get_stub() only acquires a single reference, putting it
twice would underflow the refcount and trigger dma_fence_release(). This
could result in an attempt to call kfree_rcu() on the statically allocated
dma_fence_stub global variable, causing a panic during the selftest.
Would it be better to only place dma_fence_put(stub) after the
error_put_stub label, allowing the success path to fall through and clean
it up once naturally along with the other fences?
> dma_fence_put(f4);
> error_put_f3:
> dma_fence_put(f3);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260626122836.35856-1-vulab@iscas.ac.cn?part=1
next prev parent reply other threads:[~2026-06-26 12:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-26 12:28 [PATCH] fix: dma-buf: unwrap_merge_complex: dma_fence_get_stub reference leaked on all paths WenTao Liang
2026-06-26 12:28 ` WenTao Liang
2026-06-26 12:34 ` sashiko-bot [this message]
2026-06-26 12:47 ` Christian König
2026-06-27 12:34 ` 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=20260626123455.BE3321F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
--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 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.