* [PATCH] phy: hisilicon: Fix OF node reference leak
@ 2025-11-12 6:22 Haotian Zhang
0 siblings, 0 replies; only message in thread
From: Haotian Zhang @ 2025-11-12 6:22 UTC (permalink / raw)
To: vkoul, kishon, andriy.shevchenko; +Cc: linux-phy, linux-kernel, Haotian Zhang
hi3670_pcie_get_resources_from_pcie() leaks an OF node reference
obtained by of_get_child_by_name(). The reference is not released
on any of the error paths or on successful return, causing a
reference count leak.
Fix this by declaring the device node with the __free(device_node)
cleanup construct to ensure the reference is automatically released.
Fixes: 73075011ffff ("phy: HiSilicon: Add driver for Kirin 970 PCIe PHY")
Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
---
drivers/phy/hisilicon/phy-hi3670-pcie.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/phy/hisilicon/phy-hi3670-pcie.c b/drivers/phy/hisilicon/phy-hi3670-pcie.c
index dbc7dcce682b..fc4f50aa31cd 100644
--- a/drivers/phy/hisilicon/phy-hi3670-pcie.c
+++ b/drivers/phy/hisilicon/phy-hi3670-pcie.c
@@ -558,11 +558,10 @@ static int hi3670_pcie_noc_power(struct hi3670_pcie_phy *phy, bool enable)
static int hi3670_pcie_get_resources_from_pcie(struct hi3670_pcie_phy *phy)
{
- struct device_node *pcie_port;
struct device *dev = phy->dev;
struct device *pcie_dev;
-
- pcie_port = of_get_child_by_name(dev->parent->of_node, "pcie");
+ struct device_node *pcie_port __free(device_node) =
+ of_get_child_by_name(dev->parent->of_node, "pcie");
if (!pcie_port) {
dev_err(dev, "no pcie node found in %s\n",
dev->parent->of_node->full_name);
--
2.50.1.windows.1
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2025-11-12 6:27 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-12 6:22 [PATCH] phy: hisilicon: Fix OF node reference leak Haotian Zhang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).