All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Luca Ceresoli" <luca.ceresoli@bootlin.com>
To: <sashiko-reviews@lists.linux.dev>,
	"Luca Ceresoli" <luca.ceresoli@bootlin.com>
Cc: <dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH v3 2/3] drm/vc4: dsi: stop using deprecated drmm_of_get_bridge()
Date: Tue, 13 Oct 2026 17:56:32 +0200	[thread overview]
Message-ID: <DM3U0JWSFAS4.2J8MSWTKYBDBN@bootlin.com> (raw)
In-Reply-To: <sashiko-outbox-170020@kernel.org>

On Tue Oct 13, 2026 at 5:35 PM CEST, sashiko-bot wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Medium] drm/vc4: reference leak of next_bridge on component unbind/rebind
> --
>
> commit 01a94378aeae8cb42a9f68ed6384a34ccaa162a0
> Author: Luca Ceresoli <luca.ceresoli@bootlin.com>
>
> drm/vc4: dsi: stop using deprecated drmm_of_get_bridge()
>
> drmm_of_get_bridge() is deprecated, switch to
> of_drm_get_bridge_by_endpoint(). As of_drm_get_bridge_by_endpoint() returns
> a refcounted bridge, ensure it is put by using bridge.next_bridge.
>
>> diff --git a/drivers/gpu/drm/vc4/vc4_dsi.c b/drivers/gpu/drm/vc4/vc4_dsi.c
>> index 0148f2befed14..675bd0fc13913 100644
>> --- a/drivers/gpu/drm/vc4/vc4_dsi.c
>> +++ b/drivers/gpu/drm/vc4/vc4_dsi.c
> [ ... ]
>> @@ -1775,9 +1774,13 @@ static int vc4_dsi_bind(struct device *dev, struct device *master, void *data)
>>  	if (ret)
>>  		return ret;
>>
>> +	dsi->bridge.next_bridge = drm_bridge_get(next_bridge);
>> +
>
> [Severity: Medium]
> Does this code introduce a regression that leaks the bridge reference across
> component unbind/rebind cycles?
>
> During component unbind, vc4_dsi_release_action() only drops the reference
> to dsi->bridge acquired during bind:
>
> static void vc4_dsi_release_action(struct drm_device *drm, void *ptr)
> {
> 	struct vc4_dsi *dsi = ptr;
>
> 	drm_bridge_put(&dsi->bridge);
> }
>
> Because dsi->bridge outlives the component unbind, __drm_bridge_free() is
> not executed, and the reference to next_bridge is not automatically released.
>
> When the component is subsequently rebound, vc4_dsi_bind() overwrites
> dsi->bridge.next_bridge here without freeing the previous pointer,
> permanently leaking the bridge reference. Does next_bridge need to be
> explicitly cleared in the teardown path?

Ah, right. I'm fixing this in v4 by calling
drm_bridge_clear_and_put(&dsi->bridge.next_bridge).

Not sure adding it to vc4_dsi_release_action() would be correct in case of
unbind/rebind, so I'm probably adding a new vc4_dsi_unbind() for that.

Luca

--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

  reply	other threads:[~2026-10-13 15:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-13 15:23 [PATCH v3 0/3] drm: remove deprecated *_of_get_bridge() from non-OF drivers Luca Ceresoli
2026-10-13 15:23 ` [PATCH v3 1/3] drm/vc4: dpi: stop using deprecated drmm_of_get_bridge() Luca Ceresoli
2026-10-13 15:23 ` [PATCH v3 2/3] drm/vc4: dsi: " Luca Ceresoli
2026-10-13 15:35   ` sashiko-bot
2026-10-13 15:56     ` Luca Ceresoli [this message]
2026-10-13 15:23 ` [PATCH v3 3/3] drm/vc4: dpi: inline vc4_dpi_init_bridge() into vc4_dpi_bind() Luca Ceresoli

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=DM3U0JWSFAS4.2J8MSWTKYBDBN@bootlin.com \
    --to=luca.ceresoli@bootlin.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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.