From: sashiko-bot@kernel.org
To: "Wentao Liang" <vulab@iscas.ac.cn>
Cc: neil.armstrong@linaro.org, dri-devel@lists.freedesktop.org,
linux-amlogic@lists.infradead.org
Subject: Re: [PATCH] drm/meson: Fix next_bridge reference leak in meson_encoder_dsi_probe()
Date: Wed, 16 Sep 2026 17:57:02 +0000 [thread overview]
Message-ID: <20260916175702.B32161F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260916174543.2089062-1-vulab@iscas.ac.cn>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] drm/meson: incorrect fix creates latent double-put of next_bridge
--
commit 3ff757ce4681fc8ee49157913542af343fd3e021
Author: Wentao Liang <vulab@iscas.ac.cn>
drm/meson: Fix next_bridge reference leak in meson_encoder_dsi_probe()
The commit attempts to fix a reference leak on the next bridge by manually
calling drm_bridge_put() on error paths when drm_simple_encoder_init()
or drm_bridge_attach() fails.
> diff --git a/drivers/gpu/drm/meson/meson_encoder_dsi.c b/drivers/gpu/drm/meson/meson_encoder_dsi.c
> index 3e422b612f74b..4367145d37753 100644
> --- a/drivers/gpu/drm/meson/meson_encoder_dsi.c
> +++ b/drivers/gpu/drm/meson/meson_encoder_dsi.c
> @@ -135,17 +135,21 @@ int meson_encoder_dsi_probe(struct meson_drm *priv)
> /* Encoder */
> ret = drm_simple_encoder_init(priv->drm, &meson_encoder_dsi->encoder,
> DRM_MODE_ENCODER_DSI);
> - if (ret)
> + if (ret) {
> + drm_bridge_put(meson_encoder_dsi->bridge.next_bridge);
[Severity: Medium]
Does this manual put incorrectly circumvent the bridge lifecycle API instead
of properly removing the main bridge?
The correct way to manage this reference is via the main bridge's lifecycle,
as __drm_bridge_free() automatically drops the next_bridge reference when the
main bridge is freed. Because the patch neglects to call drm_bridge_remove()
for the main bridge (which is why next_bridge was leaking in the first place),
the main bridge is left leaking in the global bridge_list.
If the main bridge leak is ever properly fixed in the future (e.g., by adding
drm_bridge_remove() or using devm_drm_bridge_add()), the manual
drm_bridge_put() introduced here will result in a double-put and
use-after-free.
> return dev_err_probe(priv->dev, ret,
> "Failed to init DSI encoder\n");
> + }
>
> meson_encoder_dsi->encoder.possible_crtcs = BIT(0);
>
> /* Attach DSI Encoder Bridge to Encoder */
> ret = drm_bridge_attach(&meson_encoder_dsi->encoder, &meson_encoder_dsi->bridge, NULL, 0);
> - if (ret)
> + if (ret) {
> + drm_bridge_put(meson_encoder_dsi->bridge.next_bridge);
[Severity: Medium]
Can this second manual cleanup also act as a latent double-put trap?
This applies the same incorrect manual cleanup on the second error path.
> return dev_err_probe(priv->dev, ret,
> "Failed to attach bridge\n");
> + }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260916174543.2089062-1-vulab@iscas.ac.cn?part=1
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
prev parent reply other threads:[~2026-09-16 17:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-16 17:45 Wentao Liang
2026-09-16 17:57 ` sashiko-bot [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=20260916175702.B32161F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-amlogic@lists.infradead.org \
--cc=neil.armstrong@linaro.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 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®