From: sashiko-bot@kernel.org
To: "Chaoyi Chen" <kernel@airkyi.com>
Cc: olteanv@gmail.com, linux-phy@lists.infradead.org,
dri-devel@lists.freedesktop.org, neil.armstrong@linaro.org,
vkoul@kernel.org
Subject: Re: [PATCH v4 1/5] drm/bridge: Implement generic USB Type-C DP HPD bridge
Date: Mon, 27 Jul 2026 06:58:19 +0000 [thread overview]
Message-ID: <20260727065819.EAFED1F00A3E@smtp.kernel.org> (raw)
In-Reply-To: <20260727064408.101-2-kernel@airkyi.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] Module load/unload cycles and dynamic Type-C port removals leak devm-managed bridges, resulting in duplicates and potential UAF.
- [High] A race condition between bus notifier registration and bus iteration causes duplicate DP HPD bridge registrations.
- [High] Unconditional bridge registration creates duplicate bridges for controllers that already register their own HPD bridge.
--
--- Patch [1]: [PATCH v4 1/5] drm/bridge: Implement generic USB Type-C DP HPD bridge ---
commit 8ca96a8d5692c2b3ff148f7a6803323281488779
Author: Chaoyi Chen <chaoyi.chen@rock-chips.com>
drm/bridge: Implement generic USB Type-C DP HPD bridge
This commit implements a generic DP HPD bridge based on aux-hpd-bridge.c.
It monitors Type-C bus events and automatically creates an HPD bridge
when a Type-C port device containing the DP svid is registered.
> diff --git a/drivers/gpu/drm/bridge/aux-hpd-typec-dp-bridge.c b/drivers/gpu/drm/bridge/aux-hpd-typec-dp-bridge.c
> new file mode 100644
> index 0000000000000..43af3ea20f201
> --- /dev/null
> +++ b/drivers/gpu/drm/bridge/aux-hpd-typec-dp-bridge.c
[ ... ]
> +static int drm_typec_bus_event(struct notifier_block *nb,
> + unsigned long action, void *data)
> +{
> + struct device *dev = (struct device *)data;
> + struct typec_altmode *alt = to_typec_altmode(dev);
> +
> + if (action != BUS_NOTIFY_ADD_DEVICE)
> + return NOTIFY_OK;
[Severity: High]
Does this code leak devm-managed bridges when a Type-C altmode device is
dynamically removed?
It looks like BUS_NOTIFY_DEL_DEVICE is not handled here, so the bridge might
linger and pin of_node references indefinitely after port removal.
> +
> + /*
> + * alt->dev.parent->parent : USB-C controller device
> + * alt->dev.parent : USB-C connector device
> + */
> + if (is_typec_port_altmode(&alt->dev) && alt->svid == USB_TYPEC_DP_SID)
> + drm_dp_hpd_bridge_register(alt->dev.parent->parent,
> + to_of_node(alt->dev.parent->fwnode));
[Severity: High]
What happens if the USB-C controller driver (like fusb302 or qcom_pmic_typec)
has already explicitly registered its own HPD bridge?
Will this unconditional registration create a second duplicate bridge? If so,
could this break of_drm_find_bridge() resolution, causing the display driver
to miss hotplug events fired on the controller's own bridge?
Additionally, because drm_dp_hpd_bridge_register() ties the devm allocation
to the external USB-C controller (alt->dev.parent->parent), will unloading
this module leave those devres allocations behind? Reloading the module might
then register duplicates.
> +
> + return NOTIFY_OK;
> +}
[ ... ]
> +static int __init drm_aux_hpd_typec_dp_bridge_module_init(void)
> +{
> + bus_register_notifier(&typec_bus, &drm_typec_event_nb);
> + /*
> + * Before module initialization, some devices may have already been added.
> + * Register the HPD bridge for these devices.
> + */
> + bus_for_each_dev(&typec_bus, NULL, NULL, check_device_already_added);
[Severity: High]
Is there a race condition between the notifier registration and the bus
iteration here?
If a Type-C altmode device is added concurrently (for example, via an async
probe of the controller) right after bus_register_notifier() but before or
during the bus_for_each_dev() iteration, could it trigger both the notifier
and the check_device_already_added callback?
Would this result in duplicate HPD bridges being registered for a single
Type-C port?
> + return 0;
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260727064408.101-1-kernel@airkyi.com?part=1
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
next prev parent reply other threads:[~2026-07-27 6:58 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-27 6:44 [PATCH v4 0/5] This series is split from the v15 "Add Type-C DP support for RK3399 EVB Chaoyi Chen
2026-07-27 6:44 ` Chaoyi Chen
2026-07-27 6:44 ` Chaoyi Chen
2026-07-27 6:44 ` [PATCH v4 1/5] drm/bridge: Implement generic USB Type-C DP HPD bridge Chaoyi Chen
2026-07-27 6:44 ` Chaoyi Chen
2026-07-27 6:44 ` Chaoyi Chen
2026-07-27 6:58 ` sashiko-bot [this message]
2026-07-27 6:44 ` [PATCH v4 2/5] drm/bridge: aux: Add drm_aux_bridge_register_from_node() Chaoyi Chen
2026-07-27 6:44 ` Chaoyi Chen
2026-07-27 6:44 ` Chaoyi Chen
2026-07-27 6:53 ` sashiko-bot
2026-07-27 6:44 ` [PATCH v4 3/5] phy: rockchip: phy-rockchip-typec: Add DRM AUX bridge Chaoyi Chen
2026-07-27 6:44 ` Chaoyi Chen
2026-07-27 6:44 ` Chaoyi Chen
2026-07-27 7:01 ` sashiko-bot
2026-07-27 6:44 ` [PATCH v4 4/5] drm/rockchip: cdn-dp: Support handle lane info without extcon Chaoyi Chen
2026-07-27 6:44 ` Chaoyi Chen
2026-07-27 6:44 ` Chaoyi Chen
2026-07-27 6:55 ` sashiko-bot
2026-07-27 6:44 ` [PATCH v4 5/5] drm/rockchip: cdn-dp: Add multiple bridges to support PHY port selection Chaoyi Chen
2026-07-27 6:44 ` Chaoyi Chen
2026-07-27 6:44 ` Chaoyi Chen
2026-07-27 6:59 ` 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=20260727065819.EAFED1F00A3E@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=kernel@airkyi.com \
--cc=linux-phy@lists.infradead.org \
--cc=neil.armstrong@linaro.org \
--cc=olteanv@gmail.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=vkoul@kernel.org \
/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.