From: Haotian Zhang <vulab@iscas.ac.cn>
To: olteanv@gmail.com, vkoul@kernel.org, kishon@kernel.org,
andriy.shevchenko@linux.intel.com
Cc: linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org,
Haotian Zhang <vulab@iscas.ac.cn>
Subject: [PATCH v2] phy: hisilicon: hi3670: Fix OF node and device reference leaks
Date: Fri, 20 Feb 2026 00:38:43 +0800 [thread overview]
Message-ID: <20260219163843.1571-1-vulab@iscas.ac.cn> (raw)
In-Reply-To: <20251112062246.852-1-vulab@iscas.ac.cn>
hi3670_pcie_get_resources_from_pcie() leaks two references:
1) The OF node returned by of_get_child_by_name() is never released.
2) The device returned by bus_find_device_by_of_node() is never put.
Fix both leaks by calling of_node_put() right after
bus_find_device_by_of_node(), and put_device() after dev_get_regmap()
when the temporary pcie_dev reference is no longer needed.
Fixes: 73075011ffff ("phy: HiSilicon: Add driver for Kirin 970 PCIe PHY")
Suggested-by: Vladimir Oltean <olteanv@gmail.com>
Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
---
Changes in v2:
- Use explicit release instead of cleanup.h infrastructure.
- Add put_device() for bus_find_device_by_of_node().
---
drivers/phy/hisilicon/phy-hi3670-pcie.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/phy/hisilicon/phy-hi3670-pcie.c b/drivers/phy/hisilicon/phy-hi3670-pcie.c
index dbc7dcce682b..35e634279794 100644
--- a/drivers/phy/hisilicon/phy-hi3670-pcie.c
+++ b/drivers/phy/hisilicon/phy-hi3670-pcie.c
@@ -570,6 +570,7 @@ static int hi3670_pcie_get_resources_from_pcie(struct hi3670_pcie_phy *phy)
}
pcie_dev = bus_find_device_by_of_node(&platform_bus_type, pcie_port);
+ of_node_put(pcie_port);
if (!pcie_dev) {
dev_err(dev, "Didn't find pcie device\n");
return -ENODEV;
@@ -584,6 +585,7 @@ static int hi3670_pcie_get_resources_from_pcie(struct hi3670_pcie_phy *phy)
* right regmap. So, let's use the named version.
*/
phy->apb = dev_get_regmap(pcie_dev, "kirin_pcie_apb");
+ put_device(pcie_dev);
if (!phy->apb) {
dev_err(dev, "Failed to get APB regmap\n");
return -ENODEV;
--
2.43.0
next prev parent reply other threads:[~2026-02-19 16:48 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-12 6:22 [PATCH] phy: hisilicon: Fix OF node reference leak Haotian Zhang
2026-02-16 8:43 ` Vladimir Oltean
2026-02-16 9:09 ` Andy Shevchenko
2026-02-16 9:11 ` Andy Shevchenko
2026-02-19 16:38 ` Haotian Zhang [this message]
2026-08-12 13:26 ` [PATCH v2] phy: hisilicon: hi3670: Fix OF node and device reference leaks Manivannan Sadhasivam
2026-09-13 10:56 ` Vinod Koul
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=20260219163843.1571-1-vulab@iscas.ac.cn \
--to=vulab@iscas.ac.cn \
--cc=andriy.shevchenko@linux.intel.com \
--cc=kishon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=olteanv@gmail.com \
--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®