All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Wentao Liang" <vulab@iscas.ac.cn>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/bridge: lt8912b: Fix next_bridge reference leak in lt8912_parse_dt()
Date: Wed, 16 Sep 2026 10:24:16 +0000	[thread overview]
Message-ID: <20260916102417.633911F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260916101401.2017498-1-vulab@iscas.ac.cn>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] drm/bridge: double-put of next_bridge on error and teardown
--

commit 836b7cdeed1872c95aba63f08e9bc717bdb9d7d6
Author: Wentao Liang <vulab@iscas.ac.cn>

drm/bridge: lt8912b: Fix next_bridge reference leak in lt8912_parse_dt()

This commit attempts to fix a reference leak by manually calling
drm_bridge_put() on the next bridge during error paths in lt8912_parse_dt()
and during driver teardown in lt8912_put_dt().

> diff --git a/drivers/gpu/drm/bridge/lontium-lt8912b.c b/drivers/gpu/drm/bridge/lontium-lt8912b.c
> index e347d04b7b2de..3bd920a43e936 100644
> --- a/drivers/gpu/drm/bridge/lontium-lt8912b.c
> +++ b/drivers/gpu/drm/bridge/lontium-lt8912b.c
> @@ -748,6 +748,7 @@ static int lt8912_parse_dt(struct lt8912 *lt)
>  	return 0;
>  
>  err_free_host_node:
> +	drm_bridge_put(lt->bridge.next_bridge);

[Severity: High]
Does this manual put operation leave a dangling pointer that will trigger a
double-put?

The lt struct is allocated via devm_drm_bridge_alloc(), which registers
a devres cleanup action that eventually calls __drm_bridge_free(). That
cleanup natively handles dropping the chained bridge reference by calling
drm_bridge_put(bridge->next_bridge).

Since this pointer isn't cleared here, will devres cleanup attempt to put
this already-freed reference again if an error occurs after
of_drm_find_and_get_bridge() succeeds (for example, if
lt8912_get_regulators() fails)?

>  	of_node_put(port_node);
>  	of_node_put(lt->host_node);
>  	return ret;
> @@ -755,6 +756,7 @@ static int lt8912_parse_dt(struct lt8912 *lt)
>  
>  static int lt8912_put_dt(struct lt8912 *lt)
>  {
> +	drm_bridge_put(lt->bridge.next_bridge);

[Severity: High]
Similarly, will this cause a double-put during driver unbind?

When the driver is unbound, lt8912_put_dt() manually drops the reference
here. Then the devres cleanup automatically drops it again using the dangling
pointer, which could lead to a refcount underflow and use-after-free of the
next DRM bridge in the chain.

Could we either rely entirely on the devres cleanup, or use something like
a clear-and-put approach to avoid leaving a dangling pointer?

>  	of_node_put(lt->host_node);
>  	return 0;
>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260916101401.2017498-1-vulab@iscas.ac.cn?part=1

      reply	other threads:[~2026-09-16 10:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-16 10:14 [PATCH] drm/bridge: lt8912b: Fix next_bridge reference leak in lt8912_parse_dt() Wentao Liang
2026-09-16 10:24 ` 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=20260916102417.633911F000FF@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.