From: sashiko-bot@kernel.org
To: "Diogo Silva" <diogompaissilva@gmail.com>
Cc: wsa+renesas@sang-engineering.com,
linux-amlogic@lists.infradead.org, imx@lists.linux.dev,
neil.armstrong@linaro.org, dri-devel@lists.freedesktop.org,
Frank.Li@kernel.org
Subject: Re: [PATCH 13/15] drm/meson: remove dependency on DRM simple helpers
Date: Sat, 18 Jul 2026 23:53:13 +0000 [thread overview]
Message-ID: <20260718235313.5C31F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260719-drm_simple_encoder_init-v1-13-a78c509e3062@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Devm lifecycle mismatch with DRM device leads to a Use-After-Free of the encoder structure if userspace holds the DRM file descriptor open after the device unbinds.
--
--- Patch [13]: [PATCH 13/15] drm/meson: remove dependency on DRM simple helpers ---
commit 2b596eefd506c3e256e80a53bf84b95edfa9824a
Author: Diogo Silva <diogompaissilva@gmail.com>
drm/meson: remove dependency on DRM simple helpers
The simple KMS helpers are deprecated because they only add an intermediate
layer between drivers and atomic modesetting. Open-code
drm_simple_encoder_init() by calling drm_encoder_init() directly and
providing driver-local drm_encoder_funcs.
> diff --git a/drivers/gpu/drm/meson/meson_encoder_cvbs.c b/drivers/gpu/drm/meson/meson_encoder_cvbs.c
> index 22cacb1660c4f..cdb84d2283f83 100644
> --- a/drivers/gpu/drm/meson/meson_encoder_cvbs.c
> +++ b/drivers/gpu/drm/meson/meson_encoder_cvbs.c
[ ... ]
> @@ -257,8 +261,9 @@ int meson_encoder_cvbs_probe(struct meson_drm *priv)
> meson_encoder_cvbs->priv = priv;
>
> /* Encoder */
> - ret = drm_simple_encoder_init(priv->drm, &meson_encoder_cvbs->encoder,
> - DRM_MODE_ENCODER_TVDAC);
> + ret = drm_encoder_init(priv->drm, &meson_encoder_cvbs->encoder,
> + &meson_encoder_cvbs_funcs,
> + DRM_MODE_ENCODER_TVDAC, NULL);
[Severity: High]
This is a pre-existing issue, but does this create a use-after-free risk
during device unbind?
In meson_encoder_cvbs_probe(), the encoder is embedded within
meson_encoder_cvbs, which is allocated via devm_drm_bridge_alloc() and tied
to the device lifetime. However, by using drm_encoder_init(), the encoder
is registered with the DRM device's lifecycle.
If a driver unbind occurs (e.g., via sysfs) while userspace holds an open
DRM file descriptor, devres will execute and free the bridge memory along
with the embedded encoder. Later, when the file descriptor is closed,
drm_mode_config_cleanup() iterates over the encoder_list and attempts to
call the encoder's destroy function on the already freed memory.
Could we use drmm_encoder_init() instead to safely tie the encoder's
lifetime to the DRM device?
This same devm vs DRM lifecycle mismatch is also present in
meson_encoder_dsi_probe() in drivers/gpu/drm/meson/meson_encoder_dsi.c and
meson_encoder_hdmi_probe() in drivers/gpu/drm/meson/meson_encoder_hdmi.c.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260719-drm_simple_encoder_init-v1-0-a78c509e3062@gmail.com?part=13
WARNING: multiple messages have this Message-ID (diff)
From: sashiko-bot@kernel.org
To: "Diogo Silva" <diogompaissilva@gmail.com>
Cc: wsa+renesas@sang-engineering.com,
linux-amlogic@lists.infradead.org, imx@lists.linux.dev,
neil.armstrong@linaro.org, dri-devel@lists.freedesktop.org,
Frank.Li@kernel.org
Subject: Re: [PATCH 13/15] drm/meson: remove dependency on DRM simple helpers
Date: Sat, 18 Jul 2026 23:53:13 +0000 [thread overview]
Message-ID: <20260718235313.5C31F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260719-drm_simple_encoder_init-v1-13-a78c509e3062@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Devm lifecycle mismatch with DRM device leads to a Use-After-Free of the encoder structure if userspace holds the DRM file descriptor open after the device unbinds.
--
--- Patch [13]: [PATCH 13/15] drm/meson: remove dependency on DRM simple helpers ---
commit 2b596eefd506c3e256e80a53bf84b95edfa9824a
Author: Diogo Silva <diogompaissilva@gmail.com>
drm/meson: remove dependency on DRM simple helpers
The simple KMS helpers are deprecated because they only add an intermediate
layer between drivers and atomic modesetting. Open-code
drm_simple_encoder_init() by calling drm_encoder_init() directly and
providing driver-local drm_encoder_funcs.
> diff --git a/drivers/gpu/drm/meson/meson_encoder_cvbs.c b/drivers/gpu/drm/meson/meson_encoder_cvbs.c
> index 22cacb1660c4f..cdb84d2283f83 100644
> --- a/drivers/gpu/drm/meson/meson_encoder_cvbs.c
> +++ b/drivers/gpu/drm/meson/meson_encoder_cvbs.c
[ ... ]
> @@ -257,8 +261,9 @@ int meson_encoder_cvbs_probe(struct meson_drm *priv)
> meson_encoder_cvbs->priv = priv;
>
> /* Encoder */
> - ret = drm_simple_encoder_init(priv->drm, &meson_encoder_cvbs->encoder,
> - DRM_MODE_ENCODER_TVDAC);
> + ret = drm_encoder_init(priv->drm, &meson_encoder_cvbs->encoder,
> + &meson_encoder_cvbs_funcs,
> + DRM_MODE_ENCODER_TVDAC, NULL);
[Severity: High]
This is a pre-existing issue, but does this create a use-after-free risk
during device unbind?
In meson_encoder_cvbs_probe(), the encoder is embedded within
meson_encoder_cvbs, which is allocated via devm_drm_bridge_alloc() and tied
to the device lifetime. However, by using drm_encoder_init(), the encoder
is registered with the DRM device's lifecycle.
If a driver unbind occurs (e.g., via sysfs) while userspace holds an open
DRM file descriptor, devres will execute and free the bridge memory along
with the embedded encoder. Later, when the file descriptor is closed,
drm_mode_config_cleanup() iterates over the encoder_list and attempts to
call the encoder's destroy function on the already freed memory.
Could we use drmm_encoder_init() instead to safely tie the encoder's
lifetime to the DRM device?
This same devm vs DRM lifecycle mismatch is also present in
meson_encoder_dsi_probe() in drivers/gpu/drm/meson/meson_encoder_dsi.c and
meson_encoder_hdmi_probe() in drivers/gpu/drm/meson/meson_encoder_hdmi.c.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260719-drm_simple_encoder_init-v1-0-a78c509e3062@gmail.com?part=13
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
next prev parent reply other threads:[~2026-07-18 23:53 UTC|newest]
Thread overview: 38+ 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 ` Diogo Silva
2026-07-18 23:35 ` [PATCH 01/15] drm/exynos: remove dependency on DRM simple helpers Diogo Silva
2026-07-18 23:35 ` Diogo Silva
2026-07-18 23:35 ` [PATCH 02/15] drm/xlnx/zynqmp_dpsub: " Diogo Silva
2026-07-18 23:35 ` Diogo Silva
2026-07-18 23:35 ` [PATCH 03/15] drm/tegra: " Diogo Silva
2026-07-18 23:35 ` Diogo Silva
2026-07-18 23:35 ` [PATCH 04/15] drm/fsl-dcu: " Diogo Silva
2026-07-18 23:35 ` Diogo Silva
2026-07-18 23:35 ` [PATCH 05/15] drm/kmb: " Diogo Silva
2026-07-18 23:35 ` Diogo Silva
2026-07-18 23:35 ` [PATCH 06/15] drm/virtio: " Diogo Silva
2026-07-18 23:35 ` Diogo Silva
2026-07-18 23:35 ` [PATCH 07/15] drm/tidss: " Diogo Silva
2026-07-18 23:35 ` Diogo Silva
2026-07-18 23:54 ` sashiko-bot
2026-07-18 23:54 ` sashiko-bot
2026-07-18 23:35 ` [PATCH 08/15] drm/imx: " Diogo Silva
2026-07-18 23:35 ` Diogo Silva
2026-07-18 23:35 ` [PATCH 09/15] drm/mediatek: " Diogo Silva
2026-07-18 23:35 ` Diogo Silva
2026-07-18 23:35 ` [PATCH 10/15] drm/renesas/shmobile: " Diogo Silva
2026-07-18 23:35 ` Diogo Silva
2026-07-18 23:35 ` [PATCH 11/15] drm/hisilicon/kirin: " Diogo Silva
2026-07-18 23:35 ` Diogo Silva
2026-07-18 23:35 ` [PATCH 12/15] drm/arm/komeda: " Diogo Silva
2026-07-18 23:35 ` Diogo Silva
2026-07-18 23:35 ` [PATCH 13/15] drm/meson: " Diogo Silva
2026-07-18 23:35 ` Diogo Silva
2026-07-18 23:53 ` sashiko-bot [this message]
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:35 ` Diogo Silva
2026-07-18 23:51 ` sashiko-bot
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
2026-07-18 23:35 ` 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=20260718235313.5C31F1F000E9@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 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.