phy: HiSilicon: Fix refcount leak in hi3670_pcie_get_resources_from_pcie
PATCH 1/1 phy: HiSilicon: Fix refcount leak in hi3670_pcie_get_resources_from_pcie
1. of_get_child_by_name() returns a node pointer with refcount incremented, we should use of_node_put() on it when done.
2. bus_find_device_by_of_node() also take a references, use put_device() to drop the reference in error handling.
Fixes 73075011ffff ("phy: HiSilicon: Add driver for Kirin 970 PCIe PHY")
Signed-off-by Miaoqian Lin <[email protected]>
--- drivers/phy/hisilicon/phy-hi3670-pcie.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/phy/hisilicon/phy-hi3670-pcie.c +2 -0
@@ -565,6 +565,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 ;
@@ -581,6 +582,7 @@ 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);return -ENODEV ; }
Signature · 7 lines
2.25.1 -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy