All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Maxime Ripard" <mripard@kernel.org>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 23/37] drm/bridge: ti-tpd12s015: Add atomic bridge state handlers
Date: Tue, 07 Jul 2026 15:43:48 +0000	[thread overview]
Message-ID: <20260707154349.69EF31F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260707-drm-all-atomic-bridges-v2-23-21d03cbca446@kernel.org>

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

Pre-existing issues:
- [High] Use-After-Release of devm-managed GPIOs if the bridge is accessed after the platform device unbinds.
- [High] Race condition where the HPD IRQ is active before its associated mutexes are initialized, and remains active after they are destroyed.
--

--- Patch [23]: [PATCH v2 23/37] drm/bridge: ti-tpd12s015: Add atomic bridge state handlers ---
commit 8627a6c33db1265257320b25744b5861c235ec83
Author: Maxime Ripard <mripard@kernel.org>

drm/bridge: ti-tpd12s015: Add atomic bridge state handlers

The ti-tpd12s015 bridge doesn't implement any enable or disable callbacks,
but is still missing the atomic state handlers. In order to remove the legacy
bridge callback support from the DRM bridge core, add them.

> diff --git a/drivers/gpu/drm/bridge/ti-tpd12s015.c b/drivers/gpu/drm/bridge/ti-tpd12s015.c
> index 136e47ad1a10d..e7b172ab7f552 100644
> --- a/drivers/gpu/drm/bridge/ti-tpd12s015.c
> +++ b/drivers/gpu/drm/bridge/ti-tpd12s015.c
[ ... ]
> @@ -96,6 +97,9 @@ static void tpd12s015_hpd_disable(struct drm_bridge *bridge)
>  }
>  
>  static const struct drm_bridge_funcs tpd12s015_bridge_funcs = {
> +	.atomic_create_state = drm_atomic_helper_bridge_create_state,
> +	.atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,
> +	.atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,
>  	.attach			= tpd12s015_attach,
>  	.detach			= tpd12s015_detach,
>  	.detect			= tpd12s015_bridge_detect,

[Severity: High]
This isn't a bug introduced by this patch, but could this detect callback
race with driver unbinding and cause a use-after-free?

The DRM core holds a reference to the bridge, allowing it to outlive the
platform device's devres lifecycle. However, the GPIO descriptors are
allocated using devm_gpiod_get_index() in tpd12s015_probe():

gpio = devm_gpiod_get_index(&pdev->dev, NULL, 2, GPIOD_IN);

If the platform device unbinds, devres frees the GPIOs. If the still-attached
bridge's detect callback (tpd12s015_detect) is then invoked by the DRM core,
it accesses the freed GPIO:

if (gpiod_get_value_cansleep(tpd->hpd_gpio))

Will this cause memory corruption or a kernel oops if the bridge is accessed
after the device unbinds?


[Severity: High]
This is another pre-existing issue, but is there a potential race condition
with the HPD IRQ and bridge mutex initialization?

In tpd12s015_probe(), the HPD IRQ is requested via devm before
drm_bridge_add() initializes bridge->hpd_mutex:

ret = devm_request_threaded_irq(&pdev->dev, tpd->hpd_irq, NULL,
                                tpd12s015_hpd_isr, ...);

If an interrupt fires immediately, tpd12s015_hpd_isr() calls
drm_bridge_hpd_notify(), which attempts to lock the uninitialized hpd_mutex.

Similarly, in tpd12s015_remove():

drm_bridge_remove(&tpd->bridge);

drm_bridge_remove() is called to destroy the mutexes while the devm-managed
IRQ is still active. Can this lead to locking an uninitialized or destroyed
mutex if the HPD pin toggles during probe or removal?

>  	.hpd_enable		= tpd12s015_hpd_enable,
>  	.hpd_disable		= tpd12s015_hpd_disable,
>  };

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260707-drm-all-atomic-bridges-v2-0-21d03cbca446@kernel.org?part=23

  reply	other threads:[~2026-07-07 15:43 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-07 15:11 [PATCH v2 00/37] drm/bridge: Convert all bridges to atomic Maxime Ripard
2026-07-07 15:11 ` [PATCH v2 01/37] drm/adp: mipi: Add atomic bridge state handlers Maxime Ripard
2026-07-07 15:29   ` sashiko-bot
2026-07-07 15:11 ` [PATCH v2 02/37] drm/bridge: analogix-anx6345: Switch to atomic bridge callbacks Maxime Ripard
2026-07-07 15:28   ` sashiko-bot
2026-07-07 15:11 ` [PATCH v2 03/37] drm/bridge: analogix-anx78xx: " Maxime Ripard
2026-07-07 15:11 ` [PATCH v2 04/37] drm/bridge: aux-bridge: Add atomic bridge state handlers Maxime Ripard
2026-07-07 15:11 ` [PATCH v2 05/37] drm/bridge: aux-hpd-bridge: " Maxime Ripard
2026-07-07 15:11 ` [PATCH v2 06/37] drm/bridge: chrontel-ch7033: Switch to atomic bridge callbacks Maxime Ripard
2026-07-07 15:11 ` [PATCH v2 07/37] drm/bridge: cros-ec-anx7688: Add atomic bridge state handlers Maxime Ripard
2026-07-07 15:29   ` sashiko-bot
2026-07-07 15:11 ` [PATCH v2 08/37] drm/bridge: lontium-lt8713sx: " Maxime Ripard
2026-07-07 15:27   ` sashiko-bot
2026-07-07 15:11 ` [PATCH v2 09/37] drm/bridge: lontium-lt8912b: Switch to atomic bridge callbacks Maxime Ripard
2026-07-07 15:11 ` [PATCH v2 10/37] drm/bridge: lontium-lt9611uxc: Add atomic bridge state handlers Maxime Ripard
2026-07-07 15:11 ` [PATCH v2 11/37] drm/bridge: lvds-codec: Switch to atomic bridge callbacks Maxime Ripard
2026-07-07 15:11 ` [PATCH v2 12/37] drm/bridge: megachips-stdpxxxx-ge-b850v3-fw: Add atomic bridge state handlers Maxime Ripard
2026-07-07 15:35   ` sashiko-bot
2026-07-07 15:11 ` [PATCH v2 13/37] drm/bridge: microchip-lvds: " Maxime Ripard
2026-07-07 15:38   ` sashiko-bot
2026-07-07 15:11 ` [PATCH v2 14/37] drm/bridge: nxp-ptn3460: Switch to atomic bridge callbacks Maxime Ripard
2026-07-07 15:41   ` sashiko-bot
2026-07-07 15:11 ` [PATCH v2 15/37] drm/bridge: of-display-mode-bridge: Add atomic bridge state handlers Maxime Ripard
2026-07-07 15:11 ` [PATCH v2 16/37] drm/bridge: parade-ps8622: Switch to atomic bridge callbacks Maxime Ripard
2026-07-07 15:39   ` sashiko-bot
2026-07-07 15:11 ` [PATCH v2 17/37] drm/bridge: sii9234: Add atomic bridge state handlers Maxime Ripard
2026-07-07 15:11 ` [PATCH v2 18/37] drm/bridge: sil-sii8620: " Maxime Ripard
2026-07-07 15:57   ` sashiko-bot
2026-07-07 15:11 ` [PATCH v2 19/37] drm/bridge: simple-bridge: Switch to atomic bridge callbacks Maxime Ripard
2026-07-07 15:11 ` [PATCH v2 20/37] drm/bridge: tc358764: " Maxime Ripard
2026-07-07 15:11 ` [PATCH v2 21/37] drm/bridge: tda998x: " Maxime Ripard
2026-07-07 15:52   ` sashiko-bot
2026-07-07 15:11 ` [PATCH v2 22/37] drm/bridge: ti-tfp410: " Maxime Ripard
2026-07-07 15:48   ` sashiko-bot
2026-07-07 15:11 ` [PATCH v2 23/37] drm/bridge: ti-tpd12s015: Add atomic bridge state handlers Maxime Ripard
2026-07-07 15:43   ` sashiko-bot [this message]
2026-07-07 15:11 ` [PATCH v2 24/37] drm/bridge: thc63lvd1024: Switch to atomic bridge callbacks Maxime Ripard
2026-07-07 15:11 ` [PATCH v2 25/37] drm/bridge: waveshare-dsi: " Maxime Ripard
2026-07-07 15:51   ` sashiko-bot
2026-07-07 15:11 ` [PATCH v2 26/37] drm/exynos: mic: " Maxime Ripard
2026-07-07 16:00   ` sashiko-bot
2026-07-07 15:11 ` [PATCH v2 27/37] drm/mcde: dsi: Add atomic bridge state handlers Maxime Ripard
2026-07-07 15:53   ` sashiko-bot
2026-07-07 15:11 ` [PATCH v2 28/37] drm/mediatek: dpi: Switch to atomic bridge callbacks Maxime Ripard
2026-07-07 15:56   ` sashiko-bot
2026-07-07 15:11 ` [PATCH v2 29/37] drm/msm: dsi: " Maxime Ripard
2026-07-07 15:11 ` [PATCH v2 30/37] drm/omap: dpi: " Maxime Ripard
2026-07-07 16:08   ` sashiko-bot
2026-07-07 15:11 ` [PATCH v2 31/37] drm/omap: dsi: " Maxime Ripard
2026-07-07 16:04   ` sashiko-bot
2026-07-07 15:11 ` [PATCH v2 32/37] drm/omap: sdi: " Maxime Ripard
2026-07-07 16:06   ` sashiko-bot
2026-07-07 15:11 ` [PATCH v2 33/37] drm/omap: venc: " Maxime Ripard
2026-07-07 16:04   ` sashiko-bot
2026-07-07 15:11 ` [PATCH v2 34/37] drm/sti: dvo: " Maxime Ripard
2026-07-07 16:09   ` sashiko-bot
2026-07-07 15:11 ` [PATCH v2 35/37] drm/sti: hda: " Maxime Ripard
2026-07-07 15:11 ` [PATCH v2 36/37] drm/sti: hdmi: " Maxime Ripard
2026-07-07 16:11   ` sashiko-bot
2026-07-07 15:11 ` [PATCH v2 37/37] drm/bridge: Remove legacy bridge callback support Maxime Ripard
2026-07-07 16:17   ` sashiko-bot
2026-07-08 17:12 ` [PATCH v2 00/37] drm/bridge: Convert all bridges to atomic 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=20260707154349.69EF31F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=mripard@kernel.org \
    --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.