From: Yige Jiang <yigejiang86@gmail.com>
To: JC Kuo <jckuo@nvidia.com>, Vinod Koul <vkoul@kernel.org>,
Thierry Reding <thierry.reding@kernel.org>,
Jonathan Hunter <jonathanh@nvidia.com>
Cc: Yige Jiang <yigejiang86@gmail.com>,
Neil Armstrong <neil.armstrong@linaro.org>,
Manivannan Sadhasivam <mani@kernel.org>,
linux-phy@lists.infradead.org, linux-tegra@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] phy: tegra: xusb: Fix OF node reference leaks in enabled pad setup
Date: Thu, 26 Nov 2026 23:59:07 +0800 [thread overview]
Message-ID: <rc-b1-20261126-vc-166-f94c6693453a@gmail.com> (raw)
tegra_xusb_pad_create() looks up the node for an enabled pad and passes
it to the SoC probe. The pad device stores that pointer in dev.of_node.
Neither the probe caller nor the pad release callback drops the lookup
reference.
Give the pad device its own node reference before device_add() and drop
it in tegra_xusb_pad_release(). The caller can then put its lookup
reference as soon as the SoC probe returns, including on error.
tegra_xusb_pad_register() also looks up the "lanes" child. The PHY
provider takes its own reference to that node. Drop the local reference
after successful registration, as the error paths already do.
I used an AI coding assistant to trace the node references and prepare
the diff and commit message.
Fixes: 53d2a715c240 ("phy: Add Tegra XUSB pad controller support")
Signed-off-by: Yige Jiang <yigejiang86@gmail.com>
---
Based on linux-next next-20261109 (630059a5a632).
Julia Lawall posted a separate fix for disabled pads in 2019:
https://lore.kernel.org/linux-tegra/1550928043-14889-5-git-send-email-Julia.Lawall@lip6.fr/
An earlier version including the disabled-pad change was compile-tested
on arm64 (GCC 14.2.0, W=1). This revision has not been compiled or
tested on Tegra hardware.
drivers/phy/tegra/xusb.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/phy/tegra/xusb.c b/drivers/phy/tegra/xusb.c
index cd1cd985f36a..aa6ede9f4a21 100644
--- a/drivers/phy/tegra/xusb.c
+++ b/drivers/phy/tegra/xusb.c
@@ -161,6 +161,7 @@ static void tegra_xusb_pad_release(struct device *dev)
{
struct tegra_xusb_pad *pad = to_tegra_xusb_pad(dev);
+ of_node_put(pad->dev.of_node);
pad->soc->ops->remove(pad);
}
@@ -178,7 +179,7 @@ int tegra_xusb_pad_init(struct tegra_xusb_pad *pad,
INIT_LIST_HEAD(&pad->list);
pad->dev.parent = padctl->dev;
pad->dev.type = &tegra_xusb_pad_type;
- pad->dev.of_node = np;
+ pad->dev.of_node = of_node_get(np);
pad->padctl = padctl;
err = dev_set_name(&pad->dev, "%s", pad->soc->name);
@@ -249,6 +250,8 @@ int tegra_xusb_pad_register(struct tegra_xusb_pad *pad,
goto remove;
}
+ of_node_put(children);
+
return 0;
remove:
@@ -285,6 +288,7 @@ tegra_xusb_pad_create(struct tegra_xusb_padctl *padctl,
return NULL;
pad = soc->ops->probe(padctl, soc, np);
+ of_node_put(np);
if (IS_ERR(pad)) {
err = PTR_ERR(pad);
dev_err(padctl->dev, "failed to create pad %s: %d\n",
base-commit: 630059a5a632377b9b7b487baccde92b7ae1dd47
reply other threads:[~2026-11-26 15:59 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=rc-b1-20261126-vc-166-f94c6693453a@gmail.com \
--to=yigejiang86@gmail.com \
--cc=jckuo@nvidia.com \
--cc=jonathanh@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=linux-tegra@vger.kernel.org \
--cc=mani@kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=thierry.reding@kernel.org \
--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
all inboxes | Powered by JetHome®