Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Diogo Silva" <diogompaissilva@gmail.com>
Cc: dri-devel@lists.freedesktop.org,
	linux-amlogic@lists.infradead.org, Frank.Li@kernel.org,
	wsa+renesas@sang-engineering.com, neil.armstrong@linaro.org,
	imx@lists.linux.dev
Subject: Re: [PATCH v2 13/15] drm/meson: remove dependency on DRM simple helpers
Date: Mon, 20 Jul 2026 15:56:50 +0000	[thread overview]
Message-ID: <20260720155651.66FCB1F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260720-drm_simple_encoder_init-v2-13-5020b630668a@gmail.com>

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

Pre-existing issues:
- [High] Potential Use-After-Free due to mixing devres (`devm_`) allocation with DRM object lifecycle.
--

--- Patch [13]: [PATCH v2 13/15] drm/meson: remove dependency on DRM simple helpers ---
commit f601252d45634d954a7087cd68009adce3fbf5f7
Author: Diogo Silva <diogompaissilva@gmail.com>

drm/meson: remove dependency on DRM simple helpers

This patch replaces the deprecated simple KMS helper drm_simple_encoder_init()
with drm_encoder_init() across the CVBS, DSI, and HDMI encoders in the meson
DRM driver.

> 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
[ ... ]
> @@ -218,6 +218,10 @@ static const struct drm_bridge_funcs meson_encoder_cvbs_bridge_funcs = {
>  	.atomic_create_state = drm_atomic_helper_bridge_create_state,
>  };
>  
> +static const struct drm_encoder_funcs meson_encoder_cvbs_funcs = {
> +	.destroy = drm_encoder_cleanup,
> +};
> +
>  int meson_encoder_cvbs_probe(struct meson_drm *priv)
>  {
[ ... ]
> @@ -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 using devres for the encoder allocation
create a use-after-free risk during device unbind?

Looking earlier in meson_encoder_cvbs_probe(), the structure containing the DRM
encoder is allocated with devres:

	meson_encoder_cvbs = devm_drm_bridge_alloc(priv->dev,
						   struct meson_encoder_cvbs,
						   bridge,
						   &meson_encoder_cvbs_bridge_funcs);

If the physical device is unbound (e.g., via sysfs) while a user application
holds a DRM file descriptor open, the devres framework will free this memory,
including the embedded struct drm_encoder.

Later, when the file descriptor is closed and the DRM core tears down the
device, it will call drm_encoder_cleanup() on the already-freed encoder.

The exact same devres allocation pattern is also present in 
meson_encoder_dsi_probe() for meson_encoder_dsi, and in
meson_encoder_hdmi_probe() for meson_encoder_hdmi.

Could these be converted to use DRM-managed allocators (like drmm_kzalloc) to
ensure the memory safely outlives the physical device unbind?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260720-drm_simple_encoder_init-v2-0-5020b630668a@gmail.com?part=13

  reply	other threads:[~2026-07-20 15:56 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-20 15:40 [PATCH v2 00/15] drm/drm_simple: remove drm_simple_encoder_init Diogo Silva
2026-07-20 15:40 ` [PATCH v2 01/15] drm/exynos: remove dependency on DRM simple helpers Diogo Silva
2026-07-20 15:52   ` sashiko-bot
2026-07-20 15:40 ` [PATCH v2 02/15] drm/xlnx/zynqmp_dpsub: " Diogo Silva
2026-07-20 17:49   ` Pandey, Radhey Shyam
2026-07-20 15:40 ` [PATCH v2 03/15] drm/tegra: " Diogo Silva
2026-07-20 15:40 ` [PATCH v2 04/15] drm/fsl-dcu: " Diogo Silva
2026-07-20 15:40 ` [PATCH v2 05/15] drm/kmb: " Diogo Silva
2026-07-20 15:40 ` [PATCH v2 06/15] drm/virtio: " Diogo Silva
2026-07-20 16:00   ` sashiko-bot
2026-07-20 15:40 ` [PATCH v2 07/15] drm/tidss: " Diogo Silva
2026-07-20 16:08   ` sashiko-bot
2026-07-20 15:40 ` [PATCH v2 08/15] drm/imx: " Diogo Silva
2026-07-20 15:40 ` [PATCH v2 09/15] drm/mediatek: " Diogo Silva
2026-07-20 15:40 ` [PATCH v2 10/15] drm/renesas/shmobile: " Diogo Silva
2026-07-20 15:40 ` [PATCH v2 11/15] drm/hisilicon/kirin: " Diogo Silva
2026-07-20 15:50   ` sashiko-bot
2026-07-20 15:40 ` [PATCH v2 12/15] drm/arm/komeda: " Diogo Silva
2026-07-20 15:40 ` [PATCH v2 13/15] drm/meson: " Diogo Silva
2026-07-20 15:56   ` sashiko-bot [this message]
2026-07-20 15:40 ` [PATCH v2 14/15] drm/drm_simple: remove deprecated drm_simple_encoder_init function Diogo Silva
2026-07-20 15:54   ` sashiko-bot
2026-07-20 15:40 ` [PATCH v2 15/15] Documentation/gpu: remove completed drm_simple_encoder_init() todo Diogo Silva
2026-07-20 16:07   ` sashiko-bot

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=20260720155651.66FCB1F00A3D@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