All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Henry Zhang" <henryzhang62@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/vc4: dsi: Allocate the encoder per DRM device
Date: Tue, 17 Nov 2026 21:14:48 +0000	[thread overview]
Message-ID: <sashiko-outbox-219679@kernel.org> (raw)
In-Reply-To: <20261117205902.1293962-1-henryzhang62@gmail.com>

Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] drm/vc4: dsi: unmanaged OF clock provider in
  vc4_dsi_init_phy_clocks() [1]
--

commit 809765ced535c89f7b7aa0f22cdfc9aa61cc56b3
Author: Henry Zhang <henryzhang62@gmail.com>

drm/vc4: dsi: Allocate the encoder per DRM device

This commit moves the VC4 DSI encoder out of struct vc4_dsi into a
DRM-managed struct vc4_dsi_encoder allocated in vc4_dsi_bind() so that
re-binding the DSI component while an older DRM device is still open does
not reuse or corrupt the old encoder.

> diff --git a/drivers/gpu/drm/vc4/vc4_dsi.c b/drivers/gpu/drm/vc4/vc4_dsi.c
> index ec008f766dd5b..5bd8f579b515a 100644
> --- a/drivers/gpu/drm/vc4/vc4_dsi.c
> +++ b/drivers/gpu/drm/vc4/vc4_dsi.c

[ ... ]

> @@ -1758,12 +1765,16 @@ static int vc4_dsi_bind(struct device *dev, struct device *master, void *data)
>  	if (ret)
>  		return ret;
>  
> -	ret = drmm_encoder_init(drm, encoder,
> -				&vc4_dsi_encoder_funcs,
> -				DRM_MODE_ENCODER_DSI,
> -				NULL);
> -	if (ret)
> -		return ret;
> +	dsi_encoder = drmm_encoder_alloc(drm, struct vc4_dsi_encoder, base.base,
> +					 &vc4_dsi_encoder_funcs,
> +					 DRM_MODE_ENCODER_DSI, NULL);
> +	if (IS_ERR(dsi_encoder))
> +		return PTR_ERR(dsi_encoder);
> +
> +	dsi_encoder->dsi = dsi;
> +	dsi_encoder->base.type = dsi->variant->port ?
> +		VC4_ENCODER_TYPE_DSI1 : VC4_ENCODER_TYPE_DSI0;
> +	encoder = &dsi_encoder->base.base;
>  
>  	ret = devm_pm_runtime_enable(dev);
>  	if (ret)

[Severity: Critical]
This problem wasn't introduced by this patch, but does
vc4_dsi_init_phy_clocks() just above this hunk leave a dangling OF clock
provider behind [1] when vc4_dsi_bind() later fails or the component
is unbound?

drivers/gpu/drm/vc4/vc4_dsi.c:vc4_dsi_init_phy_clocks() {
	dsi->clk_onecell = devm_kzalloc(dev, ...);
	...
	return of_clk_add_hw_provider(dev->of_node,
				      of_clk_hw_onecell_get,
				      dsi->clk_onecell);
}

Because vc4_dsi_init_phy_clocks() registers the provider with the unmanaged
of_clk_add_hw_provider() instead of devm_of_clk_add_hw_provider(),
unbinding the component (or failing later in vc4_dsi_bind(), such as when
drm_bridge_attach() returns -EBUSY) frees the devres-managed
dsi->clk_onecell while the provider stays on of_clk_providers, causing a
use-after-free in of_clk_hw_onecell_get() on subsequent clock lookups.

[1] https://sashiko.dev/#/bug/linux-4c5f4ec7-e4cd-4631-aa06-37e8551cebec

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261117205902.1293962-1-henryzhang62@gmail.com?part=1

  reply	other threads:[~2026-11-17 21:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 20:59 [PATCH] drm/vc4: dsi: Allocate the encoder per DRM device Henry Zhang
2026-11-17 21:14 ` sashiko-bot [this message]
2026-11-17 23:51   ` Henry Zhang

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=sashiko-outbox-219679@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=henryzhang62@gmail.com \
    --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.