Linux-Amlogic Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Diogo Silva" <diogompaissilva@gmail.com>
Cc: linux-amlogic@lists.infradead.org,
	dri-devel@lists.freedesktop.org,
	wsa+renesas@sang-engineering.com, imx@lists.linux.dev,
	Frank.Li@kernel.org, neil.armstrong@linaro.org
Subject: Re: [PATCH 07/15] drm/tidss: remove dependency on DRM simple helpers
Date: Sat, 18 Jul 2026 23:54:39 +0000	[thread overview]
Message-ID: <20260718235440.5664F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260719-drm_simple_encoder_init-v1-7-a78c509e3062@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Use-After-Free during teardown due to object lifetime mismatch between `drm_bridge` and `drm_encoder`.
--

--- Patch [7]: [PATCH 07/15] drm/tidss: remove dependency on DRM simple helpers ---
commit e6abfa8d59d485697fcfe2a3a199e7f378a7e23a
Author: Diogo Silva <diogompaissilva@gmail.com>

drm/tidss: remove dependency on DRM simple helpers

The patch removes the deprecated simple KMS helpers from the tidss driver.
It replaces drm_simple_encoder_init() with a direct call to
drm_encoder_init(), providing driver-local drm_encoder_funcs to handle
cleanup.

> diff --git a/drivers/gpu/drm/tidss/tidss_encoder.c b/drivers/gpu/drm/tidss/tidss_encoder.c
> index 698f8d964ca00..10dbcc6cdf6a8 100644
> --- a/drivers/gpu/drm/tidss/tidss_encoder.c
> +++ b/drivers/gpu/drm/tidss/tidss_encoder.c
[ ... ]
> @@ -81,6 +81,10 @@ static const struct drm_bridge_funcs tidss_bridge_funcs = {
>  	.atomic_destroy_state		= drm_atomic_helper_bridge_destroy_state,
>  };
>  
> +static const struct drm_encoder_funcs tidss_encoder_funcs = {
> +	.destroy = drm_encoder_cleanup,
> +};
> +
>  int tidss_encoder_create(struct tidss_device *tidss,
>  			 struct drm_bridge *next_bridge,
>  			 u32 encoder_type, u32 possible_crtcs)
> @@ -95,8 +99,8 @@ int tidss_encoder_create(struct tidss_device *tidss,
>  	if (IS_ERR(t_enc))
>  		return PTR_ERR(t_enc);
>  
> -	ret = drm_simple_encoder_init(&tidss->ddev, &t_enc->encoder,
> -				      encoder_type);
> +	ret = drm_encoder_init(&tidss->ddev, &t_enc->encoder,
> +			       &tidss_encoder_funcs, encoder_type, NULL);

[Severity: High]
This is a pre-existing issue, but can this lead to a use-after-free during
teardown due to mismatched object lifetimes?

In tidss_encoder_create(), the t_enc structure is allocated via
devm_drm_bridge_alloc(), which ties the memory's lifetime to the bridge's
kref.

Then the embedded encoder is initialized here and its destroy callback is set
to drm_encoder_cleanup() in tidss_encoder_funcs.

If the driver unbinds while a userspace application holds a DRM file
descriptor, devm drops the initial bridge references. Later, when the final
DRM reference is dropped, drm_mode_config_cleanup() calls the encoder's
destroy callback.

Inside drm_encoder_cleanup(), it detaches the bridge. This drops the final
kref and frees the t_enc container. However, drm_encoder_cleanup() then
continues to access the freed encoder memory, causing a use-after-free.

Does this sequence cause memory corruption during teardown?

>  	if (ret)
>  		return ret;
>

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260719-drm_simple_encoder_init-v1-0-a78c509e3062@gmail.com?part=7

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

  reply	other threads:[~2026-07-18 23:54 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-18 23:35 [PATCH 00/15] drm/drm_simple: remove drm_simple_encoder_init Diogo Silva
2026-07-18 23:35 ` [PATCH 01/15] drm/exynos: remove dependency on DRM simple helpers Diogo Silva
2026-07-20 11:05   ` Thomas Zimmermann
2026-07-20 15:15     ` Diogo Silva
2026-07-20 15:27       ` Thomas Zimmermann
2026-07-18 23:35 ` [PATCH 02/15] drm/xlnx/zynqmp_dpsub: " Diogo Silva
2026-07-18 23:35 ` [PATCH 03/15] drm/tegra: " Diogo Silva
2026-07-18 23:35 ` [PATCH 04/15] drm/fsl-dcu: " Diogo Silva
2026-07-18 23:35 ` [PATCH 05/15] drm/kmb: " Diogo Silva
2026-07-18 23:35 ` [PATCH 06/15] drm/virtio: " Diogo Silva
2026-07-18 23:35 ` [PATCH 07/15] drm/tidss: " Diogo Silva
2026-07-18 23:54   ` sashiko-bot [this message]
2026-07-18 23:35 ` [PATCH 08/15] drm/imx: " Diogo Silva
2026-07-18 23:35 ` [PATCH 09/15] drm/mediatek: " Diogo Silva
2026-07-18 23:35 ` [PATCH 10/15] drm/renesas/shmobile: " Diogo Silva
2026-07-18 23:35 ` [PATCH 11/15] drm/hisilicon/kirin: " Diogo Silva
2026-07-18 23:35 ` [PATCH 12/15] drm/arm/komeda: " Diogo Silva
2026-07-18 23:35 ` [PATCH 13/15] drm/meson: " Diogo Silva
2026-07-18 23:53   ` sashiko-bot
2026-07-18 23:35 ` [PATCH 14/15] drm/drm_simple: remove deprecated drm_simple_encoder_init function Diogo Silva
2026-07-18 23:51   ` sashiko-bot
2026-07-18 23:35 ` [PATCH 15/15] Documentation/gpu: remove completed drm_simple_encoder_init() todo Diogo Silva

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=20260718235440.5664F1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=diogompaissilva@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=imx@lists.linux.dev \
    --cc=linux-amlogic@lists.infradead.org \
    --cc=neil.armstrong@linaro.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=wsa+renesas@sang-engineering.com \
    /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