From: sashiko-bot@kernel.org
To: "Sebastian Reichel" <sebastian.reichel@collabora.com>
Cc: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org,
robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v9 01/22] drm/bridge: synopsys: dw-dp: Register DP AUX on bridge attach
Date: Mon, 03 Aug 2026 18:35:11 +0000 [thread overview]
Message-ID: <20260803183512.434FC1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260803-synopsys-dw-dp-improvements-v9-1-2e6e46135312@collabora.com>
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
New issues:
- [High] Moving `drm_dp_aux_unregister()` to the bridge `detach` callback defers it to the DRM device lifecycle, causing a Use-After-Free when the physical device is unbound.
Pre-existing issues:
- [High] Missing `reinit_completion()` before starting an AUX transfer can cause subsequent transfers to falsely complete after a timeout.
- [High] Using `devm_*` allocations in the component bind callback causes resource leaks and prevents successful rebinding.
- [High] The driver schedules `hpd_work` but never cancels it during unbind or device removal, leading to a Use-After-Free.
--
--- Patch [1]: [PATCH v9 01/22] drm/bridge: synopsys: dw-dp: Register DP AUX on bridge attach ---
commit cf33bafacfb642286c8ee7eb20855f566f32f630
Author: Sebastian Reichel <sebastian.reichel@collabora.com>
Subject: drm/bridge: synopsys: dw-dp: Register DP AUX on bridge attach
This commit moves the registration and unregistration of the DP AUX device
from the bind/unbind phases to the bridge attach/detach phases. This ensures
that the AUX device is only accessed when the DRM device is ready.
> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-dp.c b/drivers/gpu/drm/bridge/synopsys/dw-dp.c
> --- 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
> return &state->base;
> }
>
> +static int dw_dp_bridge_attach(struct drm_bridge *bridge,
> + struct drm_encoder *encoder,
> + enum drm_bridge_attach_flags flags)
> +{
> + struct dw_dp *dp = bridge_to_dp(bridge);
> + struct device *dev = dp->dev;
> + int ret;
> +
> + dp->aux.dev = dev;
> + dp->aux.drm_dev = encoder->dev;
> + dp->aux.name = dev_name(dev);
> + dp->aux.transfer = dw_dp_aux_transfer;
[Severity: High]
This is a pre-existing issue, but does dw_dp_aux_transfer() incorrectly
handle completions?
Looking at dw_dp_aux_transfer(), the code waits for a completion without
clearing any previously pending completion state:
status = wait_for_completion_timeout(&dp->complete, timeout);
If a previous hardware timeout occurred (returning 0), and the hardware later
finishes the transfer, the interrupt handler will call complete(&dp->complete).
Because reinit_completion() is not called before the next transfer, the
subsequent wait_for_completion_timeout() could instantly consume the leftover
completion and return true without waiting, reading stale or invalid status
from the hardware.
> +
> + ret = drm_dp_aux_register(&dp->aux);
> + if (ret)
> + dev_err(dev, "Aux register failed: %d\n", ret);
> +
> + return ret;
> +}
> +
> +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]
Could deferring drm_dp_aux_unregister() to the DRM device lifecycle lead to a
use-after-free when the physical device is unbound?
If a userspace process keeps the DRM device FD open, the DRM device remains
active even after the DW-DP physical device is unbound via sysfs. This triggers
devres to run for the unbound physical device, freeing dp->regmap and disabling
clocks.
Because drm_dp_aux_unregister() was moved to dw_dp_bridge_detach(), the AUX
device remains registered. If a userspace process initiates an I2C/AUX transfer
on the still-registered device node, it will call dw_dp_aux_transfer() which
dereferences the freed dp->regmap.
[ ... ]
> @@ -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_request_threaded_irq() in the
component bind callback cause resource leaks and prevent successful rebinding?
Component bind callbacks run when the master DRM device is bound. If the DRM
master is unbound, dw_dp_unbind() is called, but devres does not run because
the component platform device itself wasn't removed.
When the DRM master is bound again, dw_dp_bind() will run and attempt to
request the same exclusive IRQ, which may fail with -EBUSY and leak the prior
allocations, preventing the display pipeline from functioning.
> 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);
>
> void dw_dp_unbind(struct dw_dp *dp)
> {
> - drm_dp_aux_unregister(&dp->aux);
> + /* nothing to do */
> }
[Severity: High]
This is a pre-existing issue, but does dw_dp_unbind() need to call
cancel_work_sync(&dp->hpd_work) before the component is unbound?
The interrupt handler schedules dp->hpd_work. If an HPD interrupt fires right
before the IRQ is disabled by devres or during component unbind, the work is
queued.
When devres frees dp->regmap, and dw_dp_hpd_work() eventually executes, it
calls dw_dp_hpd_detect() which accesses the freed dp->regmap, resulting in a
use-after-free.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260803-synopsys-dw-dp-improvements-v9-0-2e6e46135312@collabora.com?part=1
next prev parent reply other threads:[~2026-08-03 18:35 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-03 18:05 [PATCH v9 00/22] Synopsys DisplayPort Controller improvements for Rockchip platforms Sebastian Reichel
2026-08-03 18:05 ` Sebastian Reichel
2026-08-03 18:05 ` [PATCH v9 01/22] drm/bridge: synopsys: dw-dp: Register DP AUX on bridge attach Sebastian Reichel
2026-08-03 18:05 ` Sebastian Reichel
2026-08-03 18:35 ` sashiko-bot [this message]
2026-08-03 18:05 ` [PATCH v9 02/22] drm/bridge: synopsys: dw-dp: Fix incorrect resource lifetimes in bind callback Sebastian Reichel
2026-08-03 18:05 ` Sebastian Reichel
2026-08-03 18:27 ` sashiko-bot
2026-08-03 18:05 ` [PATCH v9 03/22] drm/bridge: synopsys: dw-dp: Fix error handling in dw_dp_link_enable() Sebastian Reichel
2026-08-03 18:05 ` Sebastian Reichel
2026-08-03 18:25 ` sashiko-bot
2026-08-03 18:05 ` [PATCH v9 04/22] drm/bridge: synopsys: dw-dp: Cancel pending HPD work Sebastian Reichel
2026-08-03 18:05 ` Sebastian Reichel
2026-08-03 18:35 ` sashiko-bot
2026-08-03 18:05 ` [PATCH v9 05/22] drm/bridge: synopsys: dw-dp: Document missing reset line deassert Sebastian Reichel
2026-08-03 18:05 ` Sebastian Reichel
2026-08-03 18:05 ` [PATCH v9 06/22] drm/bridge: synopsys: dw-dp: Add missing mutex cleanups on module removal Sebastian Reichel
2026-08-03 18:05 ` Sebastian Reichel
2026-08-03 18:27 ` sashiko-bot
2026-08-03 18:05 ` [PATCH v9 07/22] drm/bridge: synopsys: dw-dp: Fix AUX transfer timeout race condition Sebastian Reichel
2026-08-03 18:05 ` Sebastian Reichel
2026-08-03 18:05 ` [PATCH v9 08/22] drm/bridge: synopsys: dw-dp: Fix support for short I2C reads Sebastian Reichel
2026-08-03 18:05 ` Sebastian Reichel
2026-08-03 18:05 ` [PATCH v9 09/22] drm/bridge: synopsys: dw-dp: Free output_fmts when none are valid Sebastian Reichel
2026-08-03 18:05 ` Sebastian Reichel
2026-08-03 18:35 ` sashiko-bot
2026-08-03 18:05 ` [PATCH v9 10/22] drm/bridge: synopsys: dw-dp: Support MEDIA_BUS_FMT_FIXED Sebastian Reichel
2026-08-03 18:05 ` Sebastian Reichel
2026-08-03 18:43 ` sashiko-bot
2026-08-03 18:05 ` [PATCH v9 11/22] drm/bridge: synopsys: dw-dp: Add follow-up bridge support Sebastian Reichel
2026-08-03 18:05 ` Sebastian Reichel
2026-08-03 18:05 ` [PATCH v9 12/22] drm/bridge: Add out-of-band HPD notify handler Sebastian Reichel
2026-08-03 18:05 ` Sebastian Reichel
2026-08-03 18:05 ` [PATCH v9 13/22] drm/bridge: synopsys: dw-dp: Support software triggered OOB HPD Sebastian Reichel
2026-08-03 18:05 ` Sebastian Reichel
2026-08-03 18:05 ` [PATCH v9 14/22] drm/rockchip: dw_dp: Implement out-of-band HPD handling Sebastian Reichel
2026-08-03 18:05 ` Sebastian Reichel
2026-08-03 18:46 ` sashiko-bot
2026-08-03 18:05 ` [PATCH v9 15/22] drm/bridge: synopsys: dw-dp: Add Runtime PM support Sebastian Reichel
2026-08-03 18:05 ` Sebastian Reichel
2026-08-03 18:55 ` sashiko-bot
2026-08-03 18:05 ` [PATCH v9 16/22] drm/rockchip: dw_dp: Add runtime " Sebastian Reichel
2026-08-03 18:05 ` Sebastian Reichel
2026-08-03 18:58 ` sashiko-bot
2026-08-03 18:05 ` [PATCH v9 17/22] drm/bridge: synopsys: dw-dp: Protect sdp_reg_bank from concurrent access Sebastian Reichel
2026-08-03 18:05 ` Sebastian Reichel
2026-08-03 18:05 ` [PATCH v9 18/22] drm/bridge: synopsys: dw-dp: Drop useless reservation of first slot Sebastian Reichel
2026-08-03 18:05 ` Sebastian Reichel
2026-08-03 19:02 ` sashiko-bot
2026-08-03 18:05 ` [PATCH v9 19/22] drm/bridge: synopsys: dw-dp: Clear only enabled SDPs on atomic disable Sebastian Reichel
2026-08-03 18:05 ` Sebastian Reichel
2026-08-03 18:05 ` [PATCH v9 20/22] drm/bridge: synopsys: dw-dp: Use regmap_set_bits in dw_dp_send_sdp Sebastian Reichel
2026-08-03 18:05 ` Sebastian Reichel
2026-08-03 18:05 ` [PATCH v9 21/22] dt-bindings: display: rockchip: dw-dp: Fix sound DAI cells Sebastian Reichel
2026-08-03 18:05 ` Sebastian Reichel
2026-08-03 19:06 ` sashiko-bot
2026-08-03 18:05 ` [PATCH v9 22/22] drm/bridge: synopsys: dw-dp: Add audio support Sebastian Reichel
2026-08-03 18:05 ` Sebastian Reichel
2026-08-03 19:11 ` sashiko-bot
2026-08-04 13:56 ` [PATCH v9 00/22] Synopsys DisplayPort Controller improvements for Rockchip platforms Igor Paunovic
2026-08-04 13:56 ` Igor Paunovic
2026-08-06 0:53 ` Sebastian Reichel
2026-08-06 0:53 ` Sebastian Reichel
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=20260803183512.434FC1F000E9@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 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.