dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Cristian Ciocaltea" <cristian.ciocaltea@collabora.com>
Cc: dri-devel@lists.freedesktop.org, linux-sunxi@lists.linux.dev
Subject: Re: [PATCH v11 12/74] drm/bridge: Fix unlocked list_del in drm_bridge_add()
Date: Tue, 01 Sep 2026 19:17:57 +0000	[thread overview]
Message-ID: <20260901191758.0BD4F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260901-dw-hdmi-qp-scramb-v11-12-bc12954a0688@collabora.com>

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

Pre-existing issues:
- [High] drm_bridge_remove() destroys mutexes while the bridge is still refcounted, risking a use-after-destroy.
--

commit 7791e5cbe69e4f164e69cc2e98832df9a6224dd4
Author: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>

drm/bridge: Fix unlocked list_del in drm_bridge_add()

When re-adding a bridge that was previously removed, drm_bridge_add() drops it
from bridge_lingering_list without holding bridge_lock. This commit ensures both
the list_empty() test and list_del_init() are performed under bridge_lock to
prevent list corruption.

Closes: https://lore.kernel.org/all/20260723015004.1F5711F000E9@smtp.kernel.org/

> diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
> index afaae272347c0..2c457ad74f3b3 100644
> --- a/drivers/gpu/drm/drm_bridge.c
> +++ b/drivers/gpu/drm/drm_bridge.c
> @@ -454,8 +454,10 @@ void drm_bridge_add(struct drm_bridge *bridge)
>  	 * in bridge_lingering_list. Remove it or bridge_lingering_list will be
>  	 * corrupted when adding this bridge to bridge_list below.
>  	 */
> +	mutex_lock(&bridge_lock);
>  	if (!list_empty(&bridge->list))
>  		list_del_init(&bridge->list);
> +	mutex_unlock(&bridge_lock);
>  
>  	mutex_init(&bridge->hpd_state_mutex);
>  	mutex_init(&bridge->hpd_mutex);
[Severity: High]
This is a pre-existing issue, but since we are modifying the bridge locking
here, is it safe for drm_bridge_remove() to unconditionally destroy these
mutexes while the bridge might still be refcounted?

When a bridge driver is unbound, drm_bridge_remove() calls:

	mutex_destroy(&bridge->hpd_mutex);
	mutex_destroy(&bridge->hpd_state_mutex);

If the DRM device still holds a reference to the bridge via drm_bridge_get(),
and subsequently attempts to call functions like drm_bridge_hpd_enable(), it
will lock a destroyed mutex:

	mutex_lock(&bridge->hpd_state_mutex);
	mutex_lock(&bridge->hpd_mutex);

Could this result in memory corruption or lockdep splats if the display
controller retains a reference after the bridge is removed?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260901-dw-hdmi-qp-scramb-v11-0-bc12954a0688@collabora.com?part=12

  reply	other threads:[~2026-09-01 19:18 UTC|newest]

Thread overview: 93+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-01 18:50 [PATCH v11 00/74] Add HDMI 2.0 support to DW HDMI QP TX Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 01/74] video/hdmi: Introduce HDMI version enum Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 02/74] drm/connector: hdmi: Handle reset() state allocation failure Cristian Ciocaltea
2026-09-01 19:07   ` sashiko-bot
2026-09-01 18:50 ` [PATCH v11 03/74] drm/display: hdmi: Rename drmm_connector_hdmi_init() to *_ini2() Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 04/74] drm/connector: Add drmm_connector_hdmi_init() with new signature Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 05/74] drm/display: bridge_connector: Convert to drmm_connector_hdmi_init() Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 06/74] drm/probe-helper: Introduce .force_ctx() connector callback Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 07/74] drm/connector: Add HDMI 2.0 scrambler infrastructure Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 08/74] drm/display: scdc-helper: Add macro for connector-prefixed debug messages Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 09/74] drm/display: scdc-helper: Add helper to set SCDC version information Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 10/74] drm/display: hdmi: Add HDMI 2.0 scrambling management helpers Cristian Ciocaltea
2026-09-01 19:18   ` sashiko-bot
2026-09-01 18:50 ` [PATCH v11 11/74] drm/display: hdmi: Advertise SCDC source version when scrambling Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 12/74] drm/bridge: Fix unlocked list_del in drm_bridge_add() Cristian Ciocaltea
2026-09-01 19:17   ` sashiko-bot [this message]
2026-09-01 18:50 ` [PATCH v11 13/74] drm/bridge: Fix NULL deref in drm_bridge_add() for legacy bridges Cristian Ciocaltea
2026-09-01 19:19   ` sashiko-bot
2026-09-01 18:50 ` [PATCH v11 14/74] drm/bridge: Fix unlocked list access in drm_bridge_attach() Cristian Ciocaltea
2026-09-01 19:16   ` sashiko-bot
2026-09-01 18:50 ` [PATCH v11 15/74] drm/bridge: Remove redundant error check in drm_bridge_helper_reset_crtc() Cristian Ciocaltea
2026-09-01 19:21   ` sashiko-bot
2026-09-01 18:50 ` [PATCH v11 16/74] drm/bridge: Add bridge ops for source-side HDMI 2.0 scrambling Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 17/74] drm/display: bridge_connector: Use cached connector status in .get_modes() Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 18/74] drm/display: bridge_connector: Switch to .detect_ctx() connector helper Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 19/74] drm/display: bridge_connector: Wire up HDMI 2.0 scrambler callbacks Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 20/74] drm/display: hdmi-state-helper: Add source TMDS rate validation Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 21/74] drm/display: hdmi-state-helper: Pass acquire ctx to hotplug helpers Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 22/74] drm/display: hdmi-state-helper: Add drm_atomic_helper_connector_hdmi_force_ctx() Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 23/74] drm/display: hdmi-state-helper: Sync SCDC state on hotplug Cristian Ciocaltea
2026-09-01 19:40   ` sashiko-bot
2026-09-01 18:50 ` [PATCH v11 24/74] drm/display: hdmi-state-helper: Set HDMI scrambling requirement Cristian Ciocaltea
2026-09-01 19:39   ` sashiko-bot
2026-09-01 18:50 ` [PATCH v11 25/74] drm/display: bridge_connector: Switch to .force_ctx() connector helper Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 26/74] drm/bridge: dw-hdmi-qp: Rate limit i2c read error messages Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 27/74] drm/bridge: dw-hdmi-qp: Provide .{enable,disable}_hpd() PHY ops Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 28/74] drm/bridge: dw-hdmi-qp: Remove unused workqueue include and define Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 29/74] drm/bridge: dw-hdmi-qp: Add HDMI 2.0 scrambling support Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 30/74] drm/bridge: dw-hdmi-qp: Provide dw_hdmi_qp_hpd_notify() helper Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 31/74] drm/rockchip: dw_hdmi_qp: Fix invalid drvdata access in PM ops Cristian Ciocaltea
2026-09-01 19:46   ` sashiko-bot
2026-09-01 18:50 ` [PATCH v11 32/74] drm/rockchip: dw_hdmi_qp: Cancel pending HPD work on suspend Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 33/74] drm/rockchip: dw_hdmi_qp: Add missing newlines in dev_err_probe() messages Cristian Ciocaltea
2026-09-01 19:52   ` sashiko-bot
2026-09-01 18:50 ` [PATCH v11 34/74] drm/rockchip: dw_hdmi_qp: Use local dev variable consistently in bind() Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 35/74] drm/rockchip: dw_hdmi_qp: Avoid spurious HPD IRQ thread wakeups Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 36/74] drm/rockchip: dw_hdmi_qp: Mask RK3576 HPD IRQ in io_init Cristian Ciocaltea
2026-09-01 19:50   ` sashiko-bot
2026-09-01 18:51 ` [PATCH v11 37/74] drm/rockchip: dw_hdmi_qp: Implement .{enable,disable}_hpd() PHY ops Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 38/74] drm/rockchip: dw_hdmi_qp: Factor out HPD interrupt (un)mask helpers Cristian Ciocaltea
2026-09-01 19:55   ` sashiko-bot
2026-09-01 18:51 ` [PATCH v11 39/74] drm/rockchip: dw_hdmi_qp: Control the HPD IRQ line via the bridge HPD ops Cristian Ciocaltea
2026-09-01 20:03   ` sashiko-bot
2026-09-01 18:51 ` [PATCH v11 40/74] drm/rockchip: dw_hdmi_qp: Use dw_hdmi_qp_hpd_notify() for HPD reports Cristian Ciocaltea
2026-09-01 20:05   ` sashiko-bot
2026-09-01 18:51 ` [PATCH v11 41/74] drm/bridge: dw-hdmi-qp: Drop unused .setup_hpd() phy op Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 42/74] drm/vc4: hdmi: Use common TMDS char rate constants Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 43/74] drm/vc4: hdmi: Switch to drm_hdmi_mode_needs_scrambling() Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 44/74] drm/vc4: hdmi: Switch to .force_ctx() connector helper Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 45/74] drm/vc4: hdmi: Propagate -EDEADLK to the top level Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 46/74] drm/vc4: hdmi: Convert to drmm_connector_hdmi_init() Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 47/74] drm/vc4: hdmi: Convert to common HDMI 2.0 scrambling infrastructure Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 48/74] drm/vc4: hdmi: Defer pixel clock validation to HDMI helpers Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 49/74] drm/display: hdmi-state-helper: Drop drm_atomic_helper_connector_hdmi_force() Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 50/74] drm/bridge: adv7511: Advertise HDMI 1.2 capabilities Cristian Ciocaltea
2026-09-01 20:17   ` sashiko-bot
2026-09-01 18:51 ` [PATCH v11 51/74] drm/bridge: inno-hdmi: " Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 52/74] drm/bridge: ite-it6263: Drop redundant .mode_valid hook Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 53/74] drm/bridge: ite-it6263: Advertise HDMI 1.3 capabilities Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 54/74] drm/bridge: ite-it66121: Advertise HDMI 1.2 capabilities Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 55/74] drm/bridge: lontium-lt9611: Advertise HDMI 1.4 capabilities Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 56/74] drm/rockchip: rk3066_hdmi: " Cristian Ciocaltea
2026-09-01 20:24   ` sashiko-bot
2026-09-01 18:51 ` [PATCH v11 57/74] drm/sun4i: hdmi: Convert to drmm_connector_hdmi_init() Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 58/74] drm/tests: edid: Add 4K@60Hz EDID with 600MHz TMDS Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 59/74] drm/tests: edid: Fix conformity for 1080p+4K YUV420 200MHz EDID Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 60/74] drm/tests: edid: Fix conformity for 4K RGB/YUV 340MHz EDID Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 61/74] drm/tests: bridge: Set supported HDMI version Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 62/74] drm/tests: connector: Convert to drmm_connector_hdmi_init() Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 63/74] drm/tests: connector: Add HDMI max_tmds_char_rate init coverage Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 64/74] drm/tests: connector: Add HDMI source-side scrambler coverage Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 65/74] drm/tests: hdmi_state_helper: Convert to drmm_connector_hdmi_init() Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 66/74] drm/tests: hdmi_state_helper: Add connector-provided max_tmds_char_rate coverage Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 67/74] drm/tests: hdmi_state_helper: Cover source-side scrambling decision Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 68/74] drm/connector: Remove drmm_connector_hdmi_ini2() Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 69/74] drm/connector: Drop redundant hdmi vendor/product fields Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 70/74] drm/connector: Drop redundant hdmi supported_formats field Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 71/74] drm/connector: Drop redundant max_bpc field Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 72/74] video/hdmi: Define SPD InfoFrame field lengths and use strtomem_pad() Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 73/74] drm/connector: Use the SPD InfoFrame field length defines Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 74/74] drm/tests: hdmi: Add SPD InfoFrame vendor/product coverage Cristian Ciocaltea
2026-09-02 15:28 ` [PATCH v11 00/74] Add HDMI 2.0 support to DW HDMI QP TX Igor Paunovic
2026-09-02 18:00   ` Cristian Ciocaltea

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=20260901191758.0BD4F1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=cristian.ciocaltea@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-sunxi@lists.linux.dev \
    --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