[PATCH v4 3/5] phy: rockchip: phy-rockchip-typec: Add DRM AUX bridge
sashiko-bot at kernel.org
sashiko-bot at kernel.org
Mon Jul 27 00:01:01 PDT 2026
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Missing of_node_get() causes refcount underflow (double-put) and potential use-after-free of the device node.
--
--- Patch [3]: [PATCH v4 3/5] phy: rockchip: phy-rockchip-typec: Add DRM AUX bridge ---
commit 01ab2260169a9897f73395bd29f9342205424c05
Author: Chaoyi Chen <chaoyi.chen at rock-chips.com>
phy: rockchip: phy-rockchip-typec: Add DRM AUX bridge
This commit uses the DRM_AUX_BRIDGE helper to create a transparent DRM
bridge device for the display port on Rockchip Type-C PHYs.
> diff --git a/drivers/phy/rockchip/phy-rockchip-typec.c b/drivers/phy/rockchip/phy-rockchip-typec.c
> index d9701b6106d55..48070b50416e5 100644
> --- a/drivers/phy/rockchip/phy-rockchip-typec.c
> +++ b/drivers/phy/rockchip/phy-rockchip-typec.c
[ ... ]
> @@ -1162,16 +1163,24 @@ static int rockchip_typec_phy_probe(struct platform_device *pdev)
>
> for_each_available_child_of_node(np, child_np) {
> struct phy *phy;
> + ret = 0;
>
> - if (of_node_name_eq(child_np, "dp-port"))
> + if (of_node_name_eq(child_np, "dp-port")) {
> phy = devm_phy_create(dev, child_np,
> &rockchip_dp_phy_ops);
> - else if (of_node_name_eq(child_np, "usb3-port"))
> + ret = drm_aux_bridge_register_from_node(dev, child_np);
[Severity: High]
Does this code need to call of_node_get(child_np) before passing it to
drm_aux_bridge_register_from_node()?
The iterator macro for_each_available_child_of_node() holds a reference
during the loop that it automatically drops when advancing. However, the
auxiliary device created by drm_aux_bridge_register_from_node() will
unconditionally call of_node_put() in its release function.
If we don't increment the reference count here, couldn't this result in a
refcount underflow and use-after-free when the bridge is unregistered or
destroyed?
> + } else if (of_node_name_eq(child_np, "usb3-port"))
> phy = devm_phy_create(dev, child_np,
> &rockchip_usb3_phy_ops);
> else
> continue;
>
> + if (ret) {
> + pm_runtime_disable(dev);
> + of_node_put(child_np);
> + return ret;
> + }
> +
> if (IS_ERR(phy)) {
> dev_err(dev, "failed to create phy: %pOFn\n",
> child_np);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260727064408.101-1-kernel@airkyi.com?part=3
More information about the linux-phy
mailing list