From: sashiko-bot@kernel.org
To: "Liam Zuiderhoek" <zuiderhoekl@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] GPU: drm: meson: inline call to drm_simple_encoder_init()
Date: Mon, 22 Jun 2026 19:58:54 +0000 [thread overview]
Message-ID: <20260622195855.1C9BF1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260622194649.218419-1-zuiderhoekl@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] The DRM bridge is added to the global bridge list but is not removed on subsequent error paths, leading to a Use-After-Free.
- [High] The devm-managed encoder is registered to the DRM device, causing a Use-After-Free on unbind if the DRM device outlives the platform device.
--
commit 38b3bb11e881972fb31cc13c9266c01adfa5805b
Author: Liam Zuiderhoek <zuiderhoekl@gmail.com>
GPU: drm: meson: inline call to drm_simple_encoder_init()
This commit inlines the function drm_simple_encoder_init for the meson
driver. It replaces the simple encoder init call with drm_encoder_init
and a custom cleanup struct.
> diff --git a/drivers/gpu/drm/meson/meson_encoder_hdmi.c b/drivers/gpu/drm/meson/meson_encoder_hdmi.c
> index 55c0601df3c62..0dd3a76ad959e 100644
> --- a/drivers/gpu/drm/meson/meson_encoder_hdmi.c
> +++ b/drivers/gpu/drm/meson/meson_encoder_hdmi.c
[ ... ]
> @@ -407,8 +411,9 @@ int meson_encoder_hdmi_probe(struct meson_drm *priv)
> meson_encoder_hdmi->priv = priv;
>
> /* Encoder */
> - ret = drm_simple_encoder_init(priv->drm, &meson_encoder_hdmi->encoder,
> - DRM_MODE_ENCODER_TMDS);
> + ret = drm_encoder_init(priv->drm, &meson_encoder_hdmi->encoder,
> + &drm_simple_encoder_funcs_cleanup,
> + DRM_MODE_ENCODER_TMDS, NULL);
[Severity: High]
This isn't a bug introduced by this patch, but does registering a devres
managed encoder with the DRM device cause a use-after-free during unbind?
The encoder structure is allocated earlier using devres:
meson_encoder_hdmi = devm_drm_bridge_alloc(priv->dev, ...);
It is then initialized and registered into the DRM device's mode config list
here. If the driver is unbound and the platform device is destroyed, devres
will free the encoder memory. However, if userspace holds an open DRM file
descriptor, the DRM device outlives the platform device.
When the file descriptor is later closed and the DRM device is finally
destroyed, drm_mode_config_cleanup() will attempt to call the .destroy
callback on the freed encoder memory.
> if (ret) {
> dev_err_probe(priv->dev, ret, "Failed to init HDMI encoder\n");
> goto err_put_node;
[Severity: High]
This is a pre-existing issue, but does this error path lead to a
use-after-free?
Earlier in meson_encoder_hdmi_probe(), the bridge is added to the global
bridge list:
drm_bridge_add(&meson_encoder_hdmi->bridge);
If drm_encoder_init() fails, we jump to err_put_node, which returns without
calling drm_bridge_remove(). The devres cleanup will then free
meson_encoder_hdmi, leaving a dangling pointer in the DRM core's global
bridge list.
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260622194649.218419-1-zuiderhoekl@gmail.com?part=1
next prev parent reply other threads:[~2026-06-22 19:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-22 19:46 [PATCH] GPU: drm: meson: inline call to drm_simple_encoder_init() Liam Zuiderhoek
2026-06-22 19:58 ` sashiko-bot [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-06-22 19:32 Liam Zuiderhoek
2026-06-22 19:41 ` 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=20260622195855.1C9BF1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=zuiderhoekl@gmail.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.