From: sashiko-bot@kernel.org
To: "Chaoyi Chen" <kernel@airkyi.com>
Cc: olteanv@gmail.com, vkoul@kernel.org, neil.armstrong@linaro.org,
linux-phy@lists.infradead.org
Subject: Re: [PATCH 3/5] phy: rockchip: phy-rockchip-typec: Add DRM AUX bridge
Date: Thu, 21 May 2026 05:29:57 +0000 [thread overview]
Message-ID: <20260521052958.4010F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260521032854.103-4-kernel@airkyi.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Double-free of the `child_np` device node reference leading to a Use-After-Free.
- [Medium] Incorrect error check ordering masks `devm_phy_create` failures and attempts bridge registration on invalid PHY pointers.
--
commit 83430d0b883e6ab3238d19fd9d398fef26aa6ab7
Author: Chaoyi Chen <chaoyi.chen@rock-chips.com>
phy: rockchip: phy-rockchip-typec: Add DRM AUX bridge
Using the DRM_AUX_BRIDGE helper to create the transparent DRM bridge
device.
> 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 result in a double-free of the child_np device node
reference?
The macro for_each_available_child_of_node() automatically manages the
reference count for child_np, acquiring it for the current iteration and
dropping it when advancing.
drm_aux_bridge_register_from_node() assigns the node to the auxiliary bridge
device, and the auxiliary bridge assumes ownership of a reference (calling
of_node_put() in its error paths and release callback).
Because an additional reference is not acquired via of_node_get()
before passing it, the reference is decremented twice, which can lead to a
use-after-free.
> + } 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)) {
[Severity: Medium]
Will this error check ordering mask devm_phy_create() failures?
The check for bridge registration failure (if (ret)) happens before the
check for PHY creation failure (if (IS_ERR(phy))). If devm_phy_create()
fails (e.g., returning -EPROBE_DEFER) and the subsequent bridge registration
also fails, the function will return the bridge error and mask the PHY error.
Additionally, this attempts to register the auxiliary bridge even after the
underlying PHY creation has already failed. Should IS_ERR(phy) be checked
before calling drm_aux_bridge_register_from_node(), or at least before
checking ret?
> dev_err(dev, "failed to create phy: %pOFn\n",
> child_np);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260521032854.103-1-kernel@airkyi.com?part=3
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
next prev parent reply other threads:[~2026-05-21 5:30 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-21 3:28 [PATCH 0/5] drm/bridge: Implement generic USB Type-C DP HPD bridge Chaoyi Chen
2026-05-21 3:28 ` [PATCH 1/5] " Chaoyi Chen
2026-05-21 4:35 ` sashiko-bot
2026-05-21 3:28 ` [PATCH 2/5] drm/bridge: aux: Add drm_aux_bridge_register_from_node() Chaoyi Chen
2026-05-21 4:53 ` sashiko-bot
2026-05-21 3:28 ` [PATCH 3/5] phy: rockchip: phy-rockchip-typec: Add DRM AUX bridge Chaoyi Chen
2026-05-21 5:29 ` sashiko-bot [this message]
2026-05-21 9:06 ` Heiko Stuebner
2026-05-21 3:28 ` [PATCH 4/5] drm/rockchip: cdn-dp: Support handle lane info without extcon Chaoyi Chen
2026-05-21 5:49 ` sashiko-bot
2026-05-21 3:28 ` [PATCH 5/5] drm/rockchip: cdn-dp: Add multiple bridges to support PHY port selection Chaoyi Chen
2026-05-21 6:22 ` 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=20260521052958.4010F1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox