[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20251112062246.852-1-vulab@iscas.ac.cn>
Date: Wed, 12 Nov 2025 14:22:46 +0800
From: Haotian Zhang <vulab@...as.ac.cn>
To: vkoul@...nel.org,
kishon@...nel.org,
andriy.shevchenko@...ux.intel.com
Cc: linux-phy@...ts.infradead.org,
linux-kernel@...r.kernel.org,
Haotian Zhang <vulab@...as.ac.cn>
Subject: [PATCH] phy: hisilicon: Fix OF node reference leak
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@...as.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
Powered by blists - more mailing lists