PCI: mediatek: Fix refcount leak in mtk_pcie_subsys_powerup()
authorMiaoqian Lin <linmq006@gmail.com>
Wed, 9 Mar 2022 09:19:52 +0000 (09:19 +0000)
committerLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Fri, 8 Apr 2022 14:29:44 +0000 (15:29 +0100)
The of_find_compatible_node() function returns a node pointer with
refcount incremented, We should use of_node_put() on it when done
Add the missing of_node_put() to release the refcount.

Link: https://lore.kernel.org/r/20220309091953.5630-1-linmq006@gmail.com
Fixes: 87e8657ba99c ("PCI: mediatek: Add new method to get shared pcie-cfg base address")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Miles Chen <miles.chen@mediatek.com>
Acked-by: Rob Herring <robh@kernel.org>
drivers/pci/controller/pcie-mediatek.c

index ddfbd4aebdeca6fbd961774a51bb281968c39a37..be8bd919cb88fc591b22a4622cea05d55567f4ec 100644 (file)
@@ -1008,6 +1008,7 @@ static int mtk_pcie_subsys_powerup(struct mtk_pcie *pcie)
                                           "mediatek,generic-pciecfg");
        if (cfg_node) {
                pcie->cfg = syscon_node_to_regmap(cfg_node);
+               of_node_put(cfg_node);
                if (IS_ERR(pcie->cfg))
                        return PTR_ERR(pcie->cfg);
        }