diff mbox series

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

Message ID 20220426110543.49726-1-yuancan@huawei.com
State New, archived
Headers show
Series [-next] phy: hisilicon: Add resource release in hi3670_pcie_get_resources_from_pcie | expand

Commit Message

Yuan Can April 26, 2022, 11:05 a.m. UTC
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@huawei.com>
---
 drivers/phy/hisilicon/phy-hi3670-pcie.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

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;
 	}