From: sashiko-bot@kernel.org
To: "Luca Ceresoli" <luca.ceresoli@bootlin.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 05/11] drm/bridge: panel: add a panel_bridge to every panel
Date: Fri, 14 Aug 2026 14:25:11 +0000 [thread overview]
Message-ID: <20260814142511.C06CC1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260814-drm-bridge-every-panel-v1-5-19cd5277cc8d@bootlin.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [Medium] Incorrect error check `WARN_ON(!panel->bridge)` masks bridge allocation failures, leading to invalid state.
Pre-existing issues:
- [High] Architectural Use-After-Free on panel memory when the panel unbinds.
--
--- Patch [5]: [PATCH 05/11] drm/bridge: panel: add a panel_bridge to every panel ---
commit fe7eeb215d441faca3cc4f0f4f95d9a96a4fb587
Author: Luca Ceresoli <luca.ceresoli@bootlin.com>
drm/bridge: panel: add a panel_bridge to every panel
Adding a panel does currently not add a panel_bridge wrapping it. Usually
the panel_bridge creation happens later, when some other driver (e.g. the
previous bridge or the encoder) calls *_of_get_bridge() and the following
element in the pipeline is a panel.
[ ... ]
Switch to the new approach: always create a panel_bridge with a drm_panel,
thus matching the lifetime of the drm_panel and the panel_bridge wrapping
it. This makes lifetime much more straightforward to understand and to
further develop on.
[Severity: High]
This is a pre-existing issue, but does the underlying bridge allocation
architecture have a use-after-free risk when panels unbind?
Looking at drm_panel_bridge_add_typed() in drivers/gpu/drm/bridge/panel.c:
struct drm_bridge *drm_panel_bridge_add_typed(...)
{
...
panel_bridge = devm_drm_bridge_alloc(panel->dev, struct panel_bridge,
bridge,
&panel_bridge_bridge_funcs);
...
}
Since devres automatically frees the bridge memory when the panel unbinds
(e.g., via rmmod), this completely ignores the bridge->refcount kref. For
child-parent topologies like DSI panels where fw_devlink cannot enforce
unbind ordering, couldn't the DSI host remain bound and retain a dangling
pointer to the freed bridge in its chain?
[ ... ]
> diff --git a/drivers/gpu/drm/drm_panel.c b/drivers/gpu/drm/drm_panel.c
> index f8f6082e637fd..95fc95d1b4b7a 100644
> --- a/drivers/gpu/drm/drm_panel.c
> +++ b/drivers/gpu/drm/drm_panel.c
> @@ -453,6 +453,9 @@ void *__devm_drm_panel_alloc(struct device *dev, size_t size, size_t offset,
>
> drm_panel_init(panel, dev, funcs, connector_type);
>
> + panel->bridge = devm_drm_panel_bridge_add(dev, panel);
> + WARN_ON(!panel->bridge);
[Severity: Medium]
Will this check actually catch failures? devm_drm_panel_bridge_add()
returns an ERR_PTR on failure, rather than NULL.
If the allocation fails due to memory pressure or an invalid connector
type, the warning will be silently bypassed since an ERR_PTR evaluates to
true.
The panel driver will then complete allocation successfully but with an
error pointer in panel->bridge, which can cause display controllers to
defer probing indefinitely without any error logs.
Should this use IS_ERR() instead of checking for NULL?
> +
> return container;
> }
> EXPORT_SYMBOL(__devm_drm_panel_alloc);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260814-drm-bridge-every-panel-v1-0-19cd5277cc8d@bootlin.com?part=5
next prev parent reply other threads:[~2026-08-14 14:25 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-14 14:05 [PATCH 00/11] drm/panel: add a panel_bridge to every panel Luca Ceresoli
2026-08-14 14:05 ` [PATCH 01/11] drm: of: drm_of_find_panel_or_bridge: simplify freeing the remote node pointer Luca Ceresoli
2026-08-17 8:21 ` Maxime Ripard
2026-08-14 14:05 ` [PATCH 02/11] drm: of: drm_of_find_panel_or_bridge: simplify error return paths Luca Ceresoli
2026-08-17 8:23 ` Maxime Ripard
2026-08-14 14:05 ` [PATCH 03/11] drm: of: drm_of_find_panel_or_bridge: prioritize the bridge, not the panel Luca Ceresoli
2026-08-14 14:20 ` sashiko-bot
2026-08-17 8:26 ` Maxime Ripard
2026-08-17 12:23 ` Luca Ceresoli
2026-08-14 14:05 ` [PATCH 04/11] drm/panel: merge the drm_kms_helper module into the drm module Luca Ceresoli
2026-08-14 14:13 ` sashiko-bot
2026-08-17 8:31 ` Maxime Ripard
2026-08-17 12:27 ` Luca Ceresoli
2026-08-14 14:05 ` [PATCH 05/11] drm/bridge: panel: add a panel_bridge to every panel Luca Ceresoli
2026-08-14 14:25 ` sashiko-bot [this message]
2026-08-17 14:07 ` Luca Ceresoli
2026-08-17 8:42 ` Maxime Ripard
2026-08-17 12:30 ` Luca Ceresoli
2026-08-14 14:05 ` [PATCH 06/11] drm/bridge: tc358767: don't create a panel_bridge Luca Ceresoli
2026-08-14 14:17 ` sashiko-bot
2026-08-14 14:05 ` [PATCH 07/11] drm/bridge: waveshare-dsi: " Luca Ceresoli
2026-08-14 14:05 ` [PATCH 08/11] drm/mcde: dsi: simplify device_node management using scoped for_each variant Luca Ceresoli
2026-08-14 14:19 ` sashiko-bot
2026-08-17 8:43 ` Maxime Ripard
2026-08-17 12:25 ` Linus Walleij
2026-08-17 12:34 ` Luca Ceresoli
2026-08-14 14:05 ` [PATCH 09/11] drm/mcde: dsi: don't create a panel_bridge Luca Ceresoli
2026-08-14 14:24 ` sashiko-bot
2026-08-17 12:23 ` Linus Walleij
2026-08-14 14:05 ` [PATCH 10/11] drm/bridge: fsl-ldb: " Luca Ceresoli
2026-08-14 14:18 ` sashiko-bot
2026-08-14 14:05 ` [PATCH 11/11] drm/bridge: samsung-dsim: " Luca Ceresoli
2026-08-14 14:23 ` sashiko-bot
2026-08-14 14:13 ` [PATCH 00/11] drm/panel: add a panel_bridge to every panel Luca Ceresoli
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=20260814142511.C06CC1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=luca.ceresoli@bootlin.com \
--cc=sashiko-reviews@lists.linux.dev \
/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