From: sashiko-bot@kernel.org
To: "Luca Ceresoli" <luca.ceresoli@bootlin.com>
Cc: dri-devel@lists.freedesktop.org, imx@lists.linux.dev,
Frank.Li@kernel.org
Subject: Re: [PATCH v4 26/32] drm/bridge: add drm_bridge_detach_from()
Date: Wed, 25 Nov 2026 18:15:22 +0000 [thread overview]
Message-ID: <sashiko-outbox-233940@kernel.org> (raw)
In-Reply-To: <20261125-drm-bridge-hotplug-v4-26-822722850492@bootlin.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] drm/bridge: stack list corruption and infinite loop in
drm_bridge_detach_from()
- [Medium] drm/bridge: unused static drm_bridge_detach_from() breaks
-Werror bisect
--
commit 2c3d13618a66d24a86a5bd8331f35f64a19c35c9
Author: Luca Ceresoli <luca.ceresoli@bootlin.com>
drm/bridge: add drm_bridge_detach_from()
This commit adds a helper to detach a bridge and all subsequent bridges in an
encoder's bridge chain.
> diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
> index e0e0dd7fc12bb..c00d5276e55b3 100644
> --- a/drivers/gpu/drm/drm_bridge.c
> +++ b/drivers/gpu/drm/drm_bridge.c
> @@ -504,6 +504,40 @@ int devm_drm_bridge_add(struct device *dev, struct drm_bridge *bridge)
> }
> EXPORT_SYMBOL(devm_drm_bridge_add);
>
> +/**
> + * drm_bridge_detach_from - detach a given bridge and all the following
> + * from an encoder chain
> + * @bridge: first bridge to remove
> + *
> + * Removes from an encoder all the bridges starting with a given bridge
> + * and until the end of the chain.
> + *
> + * Does nothing if the bridge is not attached to an encoder chain.
> + */
> +static void drm_bridge_detach_from(struct drm_bridge *bridge)
[Severity: Medium]
Does defining drm_bridge_detach_from() as static without any callers in this
patch break bisection under CONFIG_WERROR=y or CONFIG_DRM_WERROR=y?
drivers/gpu/drm/Makefile enables -Wunused, so compiling drm_bridge.o fails
with -Werror=unused-function until the later commit "drm/bridge: shutdown
encoder and detach downstream bridges on bridge unplug" adds the caller in
drm_bridge_remove(). Marking it __maybe_unused here (or introducing it in
the patch that uses it) avoids the build failure.
Also, the commit message still refers to the v2 name
drm_encoder_cleanup_from() instead of drm_bridge_detach_from().
> +{
> + struct drm_encoder *encoder = bridge->encoder;
> + struct drm_bridge *next;
> + LIST_HEAD(tmplist);
> +
> + /*
> + * We need the bridge_chain_mutex to modify the chain, but
> + * drm_bridge_detach() will call DRM_MODESET_LOCK_ALL_BEGIN() (in
> + * drm_modeset_lock_fini()), resulting in a possible ABBA circular
> + * deadlock. Avoid it by first moving all the bridges to a
> + * temporary list holding the lock, and then calling
> + * drm_bridge_detach() without the lock.
> + */
> + mutex_lock(&encoder->bridge_chain_mutex);
> + if (!list_empty(&bridge->chain_node))
> + list_for_each_entry_safe_from(bridge, next, &encoder->bridge_chain, chain_node)
> + list_move_tail(&bridge->chain_node, &tmplist);
> + mutex_unlock(&encoder->bridge_chain_mutex);
> +
> + while (!list_empty(&tmplist))
> + drm_bridge_detach(list_first_entry(&tmplist, struct drm_bridge, chain_node));
> +}
[Severity: High]
Can moving bridge->chain_node onto a stack-local tmplist cause list
corruption and an infinite loop if a downstream bridge is detached while
drm_bridge_detach_from() is already running?
list_move_tail(&bridge->chain_node, &tmplist) removes each bridge from
encoder->bridge_chain, but leaves bridge->chain_node non-empty while linked
into tmplist on the first caller's stack. drm_bridge_detach() only runs
list_del_init(&bridge->chain_node) after sleeping in
drm_atomic_private_obj_fini() and calling bridge->funcs->detach() without
encoder->bridge_chain_mutex held:
CPU0 CPU1
drm_bridge_detach_from(bridgeA)
mutex_lock(&bridge_chain_mutex)
list_move_tail(bridgeA, &tmplist0)
list_move_tail(bridgeB, &tmplist0)
mutex_unlock(&bridge_chain_mutex)
drm_bridge_detach(bridgeA)
drm_atomic_private_obj_fini()
drm_bridge_detach_from(bridgeB)
mutex_lock(&bridge_chain_mutex)
if (!list_empty(&bridgeB->chain_node))
list_for_each_entry_safe_from(
bridgeB, ...,
&encoder->bridge_chain, ...)
<-- walks tmplist0, never hits
&encoder->bridge_chain
Because bridgeB->chain_node is on CPU0's tmplist0 rather than
encoder->bridge_chain, CPU1's list_for_each_entry_safe_from() walks around
tmplist0 (including the stack list head itself as a struct drm_bridge),
never reaches &encoder->bridge_chain, and corrupts CPU0's stack list while
looping forever under encoder->bridge_chain_mutex.
In addition, if drm_bridge_detach() ever takes its early return on
WARN_ON(!bridge->dev), bridge->chain_node is not unlinked and
while (!list_empty(&tmplist)) spins forever.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261125-drm-bridge-hotplug-v4-0-822722850492@bootlin.com?part=26
next prev parent reply other threads:[~2026-11-25 18:15 UTC|newest]
Thread overview: 69+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 17:50 [PATCH v4 00/32] drm bridge hotplug Luca Ceresoli
2026-11-25 17:50 ` [PATCH v4 01/32] drm/display: hdmi-cec-helper: use drmm_ prefix for drmm action Luca Ceresoli
2026-12-01 10:20 ` Maxime Ripard
2026-11-25 17:50 ` [PATCH v4 02/32] drm/display: hdmi-cec-helper: add non-drmm API variant Luca Ceresoli
2026-11-25 18:08 ` sashiko-bot
2026-12-01 10:21 ` Maxime Ripard
2026-11-25 17:50 ` [PATCH v4 03/32] drm/display: hdmi-cec-notifier-helper: use drmm_ prefix for drmm action Luca Ceresoli
2026-12-01 10:21 ` Maxime Ripard
2026-11-25 17:50 ` [PATCH v4 04/32] drm/display: hdmi-cec-notifier-helper: add non-drmm API variant Luca Ceresoli
2026-11-25 18:07 ` sashiko-bot
2026-12-01 10:22 ` Maxime Ripard
2026-11-25 17:50 ` [PATCH v4 05/32] drm/connector: split drmm_connector_hdmi_init() in 3 parts Luca Ceresoli
2026-11-25 17:50 ` [PATCH v4 06/32] drm/connector: add drm_connector_hdmi_dynamic_init() Luca Ceresoli
2026-11-25 18:10 ` sashiko-bot
2026-11-25 17:50 ` [PATCH v4 07/32] drm/display: bridge-connector: split allocation code from initialization code Luca Ceresoli
2026-11-25 17:50 ` [PATCH v4 08/32] drm/display: bridge-connector: hoist error management to common code Luca Ceresoli
2026-11-25 18:03 ` sashiko-bot
2026-12-01 10:30 ` Maxime Ripard
2026-11-25 17:50 ` [PATCH v4 09/32] drm/display: bridge-connector: use a dynamic connector Luca Ceresoli
2026-11-25 18:21 ` sashiko-bot
2026-11-26 1:15 ` kernel test robot
2026-11-25 17:50 ` [PATCH v4 10/32] drm/display: bridge-connector: add APIs to add/remove the connector dynamically Luca Ceresoli
2026-11-25 18:14 ` sashiko-bot
2026-11-25 17:50 ` [PATCH v4 11/32] drm/bridge: constify of_drm_find_and_get_bridge() device_node parameter Luca Ceresoli
2026-11-25 17:59 ` sashiko-bot
2026-12-01 10:30 ` Maxime Ripard
2026-11-25 17:50 ` [PATCH v4 12/32] drm/bridge: initialize chain_node list head on allocation Luca Ceresoli
2026-12-01 10:31 ` Maxime Ripard
2026-11-25 17:50 ` [PATCH v4 13/32] drm/bridge: initialize chain_node list head on detach and attach errors Luca Ceresoli
2026-12-01 10:31 ` Maxime Ripard
2026-11-25 17:50 ` [PATCH v4 14/32] drm/bridge: ti-sn65dsi86: protect device resources on unplug Luca Ceresoli
2026-11-25 18:16 ` sashiko-bot
2026-12-01 10:23 ` Maxime Ripard
2026-11-25 17:50 ` [PATCH v4 15/32] drm/atomic: drm_atomic_private_obj_fini: protect private_obj removal from list Luca Ceresoli
2026-11-25 18:12 ` sashiko-bot
2026-11-25 17:50 ` [PATCH v4 16/32] drm/probe-helper: add per-connector polling enable/disable Luca Ceresoli
2026-11-25 18:10 ` sashiko-bot
2026-12-01 10:32 ` Maxime Ripard
2026-11-25 17:50 ` [PATCH v4 17/32] drm: event-notifier: add mechanism to notify about hotplug events Luca Ceresoli
2026-11-25 17:50 ` [PATCH v4 18/32] drm/bridge: notify about added and detached bridges Luca Ceresoli
2026-11-25 17:50 ` [PATCH v4 19/32] drm/mipi-dsi: notify about DSI attach Luca Ceresoli
2026-11-25 17:50 ` [PATCH v4 20/32] drm/bridge: add drm_bridge_get_next() and supporting func Luca Ceresoli
2026-12-01 10:40 ` Maxime Ripard
2026-11-25 17:50 ` [PATCH v4 21/32] drm/panel: implement .get_next_bridge Luca Ceresoli
2026-12-01 10:36 ` Maxime Ripard
2026-11-25 17:50 ` [PATCH v4 22/32] drm/bridge: display-connector: " Luca Ceresoli
2026-12-01 10:41 ` Maxime Ripard
2026-11-25 17:50 ` [PATCH v4 23/32] drm/bridge: ti-sn65dsi83: " Luca Ceresoli
2026-11-25 18:14 ` sashiko-bot
2026-11-25 17:50 ` [PATCH v4 24/32] drm/bridge: ti-sn65dsi86: " Luca Ceresoli
2026-11-25 18:18 ` sashiko-bot
2026-11-25 17:50 ` [PATCH v4 25/32] drm/bridge: samsung-dsim: " Luca Ceresoli
2026-11-25 18:15 ` sashiko-bot
2026-11-25 17:50 ` [PATCH v4 26/32] drm/bridge: add drm_bridge_detach_from() Luca Ceresoli
2026-11-25 18:15 ` sashiko-bot [this message]
2026-11-25 17:50 ` [PATCH v4 27/32] drm/atomic: add drm_atomic_shutdown_encoder() Luca Ceresoli
2026-12-01 15:19 ` Maxime Ripard
2026-11-25 17:50 ` [PATCH v4 28/32] drm/tests: atomic: add tests for drm_atomic_shutdown_encoder() Luca Ceresoli
2026-11-25 17:50 ` [PATCH v4 29/32] drm/bridge: clear bridge->encoder on detach Luca Ceresoli
2026-12-01 15:24 ` Maxime Ripard
2026-11-25 17:50 ` [PATCH v4 30/32] drm/bridge: shutdown encoder and detach downstream bridges on bridge unplug Luca Ceresoli
2026-11-25 18:28 ` sashiko-bot
2026-11-25 17:50 ` [PATCH v4 31/32] drm: drm_hotplug_helper: new helper to implement bridge hotplug Luca Ceresoli
2026-11-25 18:30 ` sashiko-bot
2026-12-01 16:06 ` Maxime Ripard
2026-11-25 17:50 ` [PATCH v4 32/32] drm/mxsfb/lcdif: enable " Luca Ceresoli
2026-11-25 18:31 ` sashiko-bot
2026-11-26 3:23 ` kernel test robot
2026-11-26 5:12 ` kernel test robot
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=sashiko-outbox-233940@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=imx@lists.linux.dev \
--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 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.