@@ -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;
}
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(+)