Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Sebastian Reichel" <sebastian.reichel@collabora.com>
Cc: devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org,
	robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v10 01/21] drm/bridge: synopsys: dw-dp: Register DP AUX on bridge attach
Date: Thu, 06 Aug 2026 01:02:07 +0000	[thread overview]
Message-ID: <20260806010208.A26351F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260806-synopsys-dw-dp-improvements-v10-1-d84a26c303d6@collabora.com>

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

New issues:
- [High] Moving `drm_dp_aux_unregister()` to the bridge `detach` callback leaves the AUX character device exposed to userspace after the component is unbound, leading to a Use-After-Free and hardware fault.

Pre-existing issues:
- [High] Incorrect use of `devm_` APIs on the component device in `dw_dp_bind` causes permanent resource leaks and a fatal NULL pointer dereference on unbind.
--

--- Patch [1]: [PATCH v10 01/21] drm/bridge: synopsys: dw-dp: Register DP AUX on bridge attach ---
commit 1118ca21508c977536ef793f4a69acdf62b0bbbb
Author: Sebastian Reichel <sebastian.reichel@collabora.com>

drm/bridge: synopsys: dw-dp: Register DP AUX on bridge attach

This commit delays the DP AUX device registration until the bridge attach
callback, ensuring the DRM device is ready and the bridge is initialized.
It also moves the unregistration from the component unbind callback to the
bridge detach callback.

> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-dp.c b/drivers/gpu/drm/bridge/synopsys/dw-dp.c
> index 3445c82e6f50e..112a499113095 100644
> --- a/drivers/gpu/drm/bridge/synopsys/dw-dp.c
> +++ b/drivers/gpu/drm/bridge/synopsys/dw-dp.c
[ ... ]
> @@ -1813,7 +1813,36 @@ static struct drm_bridge_state *dw_dp_bridge_atomic_duplicate_state(struct drm_b
[ ... ]
> +static void dw_dp_bridge_detach(struct drm_bridge *bridge)
> +{
> +	struct dw_dp *dp = bridge_to_dp(bridge);
> +
> +	drm_dp_aux_unregister(&dp->aux);
> +}

[Severity: High]
Does moving drm_dp_aux_unregister() to the bridge detach callback leave the AUX
character device exposed to userspace after the component is unbound?

If a userspace process opens the DRM device, holding a reference, and the
dw_dp driver is unbound (e.g., via sysfs), the component unbind callback will
now do nothing, leaving the AUX device registered.

The component devres handlers will then execute, freeing dp->regmap and
dp->phy, and releasing the MMIO mappings.

Since dw_dp_bridge_detach() relies on drmm cleanup, its execution is delayed
until the userspace process closes the DRM file descriptor.

If userspace initiates a read or write on the still-registered
/dev/drm_dp_auxN character device during this time, dw_dp_aux_transfer()
could attempt to write to the unmapped and freed dp->regmap, resulting in a
hardware fault or kernel panic.

[ ... ]
> @@ -2065,37 +2084,33 @@ struct dw_dp *dw_dp_bind(struct device *dev, struct drm_encoder *encoder,
[ ... ]
>  	ret = devm_request_threaded_irq(dev, dp->irq, NULL, dw_dp_irq,
>  					IRQF_ONESHOT, dev_name(dev), dp);

[Severity: High]
This is a pre-existing issue, but does using devm_ APIs like
devm_request_threaded_irq() inside dw_dp_bind() tie the resource to the
component device's probe/remove lifecycle rather than the bind/unbind
lifecycle?

When the master DRM driver unbinds, the component .unbind hook is called, but
devres on the component device does not run because the component driver
itself was not removed.

This leaves the IRQ handler active. When the master DRM device's drmm cleanup
runs, it triggers drm_bridge_detach(), which explicitly sets dp->bridge.dev
to NULL.

If a hotplug event then triggers the active IRQ, it schedules dw_dp_hpd_work():

drivers/gpu/drm/bridge/synopsys/dw-dp.c:dw_dp_hpd_work() {
    ...
    drm_helper_hpd_irq_event(dp->bridge.dev);
    ...
}

Will this dereference the NULL dp->bridge.dev pointer and crash the kernel?

Additionally, if the master DRM driver attempts to rebind, will dw_dp_bind()
fail with -EBUSY when calling devm_request_threaded_irq() because the previous
allocation leaked?

>  	if (ret) {
>  		dev_err_probe(dev, ret, "failed to request irq\n");
> -		goto unregister_aux;
> +		return ERR_PTR(ret);
>  	}
>  
>  	return dp;
> -
> -unregister_aux:
> -	drm_dp_aux_unregister(&dp->aux);
> -	return ERR_PTR(ret);
>  }
>  EXPORT_SYMBOL_GPL(dw_dp_bind);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260806-synopsys-dw-dp-improvements-v10-0-d84a26c303d6@collabora.com?part=1

  reply	other threads:[~2026-08-06  1:02 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-06  0:39 [PATCH v10 00/21] Synopsys DisplayPort Controller improvements for Rockchip platforms Sebastian Reichel
2026-08-06  0:39 ` [PATCH v10 01/21] drm/bridge: synopsys: dw-dp: Register DP AUX on bridge attach Sebastian Reichel
2026-08-06  1:02   ` sashiko-bot [this message]
2026-08-06  0:39 ` [PATCH v10 02/21] drm/bridge: synopsys: dw-dp: Fix incorrect resource lifetimes in bind callback Sebastian Reichel
2026-08-06  1:05   ` sashiko-bot
2026-08-06  0:39 ` [PATCH v10 03/21] drm/bridge: synopsys: dw-dp: Fix error handling for DP link enablement Sebastian Reichel
2026-08-06  0:59   ` sashiko-bot
2026-08-06  0:39 ` [PATCH v10 04/21] drm/bridge: synopsys: dw-dp: Document missing reset line deassert Sebastian Reichel
2026-08-06  0:58   ` sashiko-bot
2026-08-06  0:39 ` [PATCH v10 05/21] drm/bridge: synopsys: dw-dp: Add missing mutex cleanups on module removal Sebastian Reichel
2026-08-06  0:58   ` sashiko-bot
2026-08-06  0:39 ` [PATCH v10 06/21] drm/bridge: synopsys: dw-dp: Fix AUX transfer timeout race condition Sebastian Reichel
2026-08-06  1:05   ` sashiko-bot
2026-08-06  0:39 ` [PATCH v10 07/21] drm/bridge: synopsys: dw-dp: Fix support for short I2C reads Sebastian Reichel
2026-08-06  0:39 ` [PATCH v10 08/21] drm/bridge: synopsys: dw-dp: Free output_fmts when none are valid Sebastian Reichel
2026-08-06  0:39 ` [PATCH v10 09/21] drm/bridge: synopsys: dw-dp: Support MEDIA_BUS_FMT_FIXED Sebastian Reichel
2026-08-06  0:39 ` [PATCH v10 10/21] drm/bridge: synopsys: dw-dp: Add follow-up bridge support Sebastian Reichel
2026-08-06  1:01   ` sashiko-bot
2026-08-06  0:39 ` [PATCH v10 11/21] drm/bridge: Add out-of-band HPD notify handler Sebastian Reichel
2026-08-06  0:39 ` [PATCH v10 12/21] drm/bridge: synopsys: dw-dp: Support software triggered OOB HPD Sebastian Reichel
2026-08-06  0:39 ` [PATCH v10 13/21] drm/rockchip: dw_dp: Implement out-of-band HPD handling Sebastian Reichel
2026-08-06  0:58   ` sashiko-bot
2026-08-06  0:39 ` [PATCH v10 14/21] drm/bridge: synopsys: dw-dp: Add Runtime PM support Sebastian Reichel
2026-08-06  1:07   ` sashiko-bot
2026-08-06  0:39 ` [PATCH v10 15/21] drm/rockchip: dw_dp: Add runtime " Sebastian Reichel
2026-08-06  1:06   ` sashiko-bot
2026-08-06  0:39 ` [PATCH v10 16/21] drm/bridge: synopsys: dw-dp: Protect sdp_reg_bank from concurrent access Sebastian Reichel
2026-08-06  0:39 ` [PATCH v10 17/21] drm/bridge: synopsys: dw-dp: Drop useless reservation of first slot Sebastian Reichel
2026-08-06  0:39 ` [PATCH v10 18/21] drm/bridge: synopsys: dw-dp: Clear only enabled SDPs on atomic disable Sebastian Reichel
2026-08-06  0:39 ` [PATCH v10 19/21] drm/bridge: synopsys: dw-dp: Use regmap_set_bits in dw_dp_send_sdp Sebastian Reichel
2026-08-06  0:39 ` [PATCH v10 20/21] dt-bindings: display: rockchip: dw-dp: Fix sound DAI cells Sebastian Reichel
2026-08-06  1:06   ` sashiko-bot
2026-08-06  0:39 ` [PATCH v10 21/21] drm/bridge: synopsys: dw-dp: Add audio support Sebastian Reichel
2026-08-06  1:10   ` sashiko-bot

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=20260806010208.A26351F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=sebastian.reichel@collabora.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox