[PATCH -next] phy: hisilicon: Add resource release in hi3670_pcie_get_resources_from_pcie

Yuan Can yuancan at huawei.com
Tue Apr 26 04:05:43 PDT 2022


Reference count of pcie_port and pcie_dev should be decremented when
error occurs.

Fixes: 73075011ffff8 (phy: HiSilicon: Add driver for Kirin 970 PCIe PHY)
Signed-off-by: Yuan Can <yuancan at huawei.com>
---
 drivers/phy/hisilicon/phy-hi3670-pcie.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/phy/hisilicon/phy-hi3670-pcie.c b/drivers/phy/hisilicon/phy-hi3670-pcie.c
index 0ac9634b398d..77c9c72d939e 100644
--- a/drivers/phy/hisilicon/phy-hi3670-pcie.c
+++ b/drivers/phy/hisilicon/phy-hi3670-pcie.c
@@ -567,6 +567,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);
 	if (!pcie_dev) {
 		dev_err(dev, "Didn't find pcie device\n");
+		of_node_put(pcie_port);
 		return -ENODEV;
 	}
 
@@ -581,6 +582,8 @@ static int hi3670_pcie_get_resources_from_pcie(struct hi3670_pcie_phy *phy)
 	phy->apb = dev_get_regmap(pcie_dev, "kirin_pcie_apb");
 	if (!phy->apb) {
 		dev_err(dev, "Failed to get APB regmap\n");
+		put_device(pcie_dev);
+		of_node_put(pcie_port);
 		return -ENODEV;
 	}
 
-- 
2.17.1




More information about the linux-phy mailing list