From: sashiko-bot@kernel.org
To: "Albert Esteve" <aesteve@redhat.com>
Cc: Frank.Li@kernel.org, dri-devel@lists.freedesktop.org,
imx@lists.linux.dev, linux-sunxi@lists.linux.dev,
wsa+renesas@sang-engineering.com
Subject: Re: [PATCH v3 4/4] drm/panel: find_panel_by_fwnode() return a counted reference
Date: Fri, 17 Jul 2026 14:14:19 +0000 [thread overview]
Message-ID: <20260717141420.2500C1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260717-drm_refcount_wiring-v3-4-023900c32e01@redhat.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] TOCTOU race condition in `drm_panel_add_follower` leading to Use-After-Free of `panel->dev`.
--
--- Patch [4]: [PATCH v3 4/4] drm/panel: find_panel_by_fwnode() return a counted reference ---
commit 2c073e53f181794d94244eff0882b1f1a661d995
Author: Albert Esteve <aesteve@redhat.com>
drm/panel: find_panel_by_fwnode() return a counted reference
This patch updates find_panel_by_fwnode() to return a reference-counted
drm_panel pointer, preventing the panel's container memory from being
released prematurely. It also updates drm_panel_remove_follower() to
balance the reference with drm_panel_put().
> diff --git a/drivers/gpu/drm/drm_panel.c b/drivers/gpu/drm/drm_panel.c
> index 72cf86253c0cd..a00ae98ed0956 100644
> --- a/drivers/gpu/drm/drm_panel.c
> +++ b/drivers/gpu/drm/drm_panel.c
[ ... ]
> @@ -554,6 +560,7 @@ static struct drm_panel *find_panel_by_fwnode(const struct fwnode_handle *fwnode
>
> list_for_each_entry(panel, &panel_list, list) {
> if (dev_fwnode(panel->dev) == fwnode) {
> + drm_panel_get(panel);
> mutex_unlock(&panel_lock);
[Severity: High]
This is a pre-existing issue, but does releasing the panel_lock here leave
a TOCTOU race window where panel->dev can be freed before it's used by the
caller?
If the panel's device is unregistered concurrently (e.g., via sysfs unbind
of its parent), the following sequence seems possible:
CPU1 in find_panel_by_fwnode():
drm_panel_get(panel);
mutex_unlock(&panel_lock);
return panel;
CPU2 concurrently unregisters the device:
drm_panel_remove() runs, removing the panel from panel_list.
The device's reference count drops to zero and the struct device behind
panel->dev is freed.
CPU1 in drm_panel_add_follower():
get_device(panel->dev);
Since panel->dev now points to a freed device, could this cause a
use-after-free?
> return panel;
> }
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260717-drm_refcount_wiring-v3-0-023900c32e01@redhat.com?part=4
prev parent reply other threads:[~2026-07-17 14:14 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-17 14:02 [PATCH v3 0/4] drm/panel: refcounting panel lookups and references Albert Esteve
2026-07-17 14:02 ` Albert Esteve
2026-07-17 14:02 ` [PATCH v3 1/4] drm/panel: have drm_panel_add/remove manage a list reference Albert Esteve
2026-07-17 14:02 ` Albert Esteve
2026-07-17 14:31 ` sashiko-bot
2026-07-17 14:02 ` [PATCH v3 2/4] drm/bridge/panel: hold a reference to the wrapped panel Albert Esteve
2026-07-17 14:02 ` Albert Esteve
2026-07-17 14:15 ` sashiko-bot
2026-07-17 14:02 ` [PATCH v3 3/4] drm/panel: of_drm_find_panel() return a counted reference Albert Esteve
2026-07-17 14:02 ` Albert Esteve
2026-07-17 14:24 ` sashiko-bot
2026-07-17 14:02 ` [PATCH v3 4/4] drm/panel: find_panel_by_fwnode() " Albert Esteve
2026-07-17 14:02 ` Albert Esteve
2026-07-17 14:14 ` sashiko-bot [this message]
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=20260717141420.2500C1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=aesteve@redhat.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=imx@lists.linux.dev \
--cc=linux-sunxi@lists.linux.dev \
--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.