Skip to contentSkip to conversation

PCI: mediatek: Fix refcount leak in mtk_pcie_subsys_powerup

PATCH Applied Miaoqian Lin 5 participants 5 messages Mar 9, 2022 – Apr 8, 2022

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI: mediatek: Fix refcount leak in mtk_pcie_subsys_powerup

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.

Fixes 87e8657ba99c ("PCI: mediatek: Add new method to get shared pcie-cfg base address")
---
 drivers/pci/controller/pcie-mediatek.c | 1 +
 1 file changed, 1 insertion(+)
drivers/pci/controller/pcie-mediatek.c +1 -0
index ddfbd4aebdec..be8bd919cb88 100644
@@ -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);
 	}
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw

Hi Miaoqian,

Quoted 15 lines

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.

Fixes 87e8657ba99c ("PCI: mediatek: Add new method to get shared pcie-cfg base address")
---
 drivers/pci/controller/pcie-mediatek.c | 1 +
 1 file changed, 1 insertion(+)
drivers/pci/controller/pcie-mediatek.c +0 -0
index ddfbd4aebdec..be8bd919cb88 100644

drivers/pci/controller/pcie-mediatek.c static int mtk_pcie_subsys_powerup(struct mtk_pcie *pcie) · line 1014

Quoted 7 lines
drivers/pci/controller/pcie-mediatek.c +1 -0
@@ -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);
 	}

Thanks for this patch.

Thanks,
Miles

maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Miaoqian Lin

Il 09/03/22 10:19, Miaoqian Lin ha scritto:

Quoted 7 lines

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.

Fixes 87e8657ba99c ("PCI: mediatek: Add new method to get shared pcie-cfg base address")
Quoted 10 lines
---
  drivers/pci/controller/pcie-mediatek.c | 1 +
  1 file changed, 1 insertion(+)
drivers/pci/controller/pcie-mediatek.c +0 -0
index ddfbd4aebdec..be8bd919cb88 100644

drivers/pci/controller/pcie-mediatek.c static int mtk_pcie_subsys_powerup(struct mtk_pcie *pcie) · line 1014

Quoted 7 lines
drivers/pci/controller/pcie-mediatek.c +1 -0
@@ -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);
  	}

_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek

reviewer Acked-by on v1 1/1
#3 lore raw
In reply to Miaoqian Lin
Quoted 9 lines · Miaoqian Lin

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.

Fixes 87e8657ba99c ("PCI: mediatek: Add new method to get shared pcie-cfg base address")
---
 drivers/pci/controller/pcie-mediatek.c | 1 +
 1 file changed, 1 insertion(+)