All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] PCI: kirin: Fix of_node_put() issue in pcie-kirin
@ 2021-11-05  2:07 Wan Jiabing
  2021-11-05 18:59 ` Bjorn Helgaas
  0 siblings, 1 reply; 2+ messages in thread
From: Wan Jiabing @ 2021-11-05  2:07 UTC (permalink / raw)
  To: Xiaowei Song, Binghui Wang, Lorenzo Pieralisi, Rob Herring,
	Krzysztof Wilczyński, Bjorn Helgaas, linux-pci,
	linux-kernel
  Cc: jiabing.wan, mchehab+huawei, Wan Jiabing

Fix following coccicheck warning:
./drivers/pci/controller/dwc/pcie-kirin.c:414:2-34: WARNING: Function
for_each_available_child_of_node should have of_node_put() before return.

Early exits from for_each_available_child_of_node should decrement the
node reference counter. Replace return by goto here and add a missing
of_node_put for parent.

Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>
---
 drivers/pci/controller/dwc/pcie-kirin.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/controller/dwc/pcie-kirin.c b/drivers/pci/controller/dwc/pcie-kirin.c
index 06017e826832..b72a12bac49d 100644
--- a/drivers/pci/controller/dwc/pcie-kirin.c
+++ b/drivers/pci/controller/dwc/pcie-kirin.c
@@ -422,7 +422,8 @@ static int kirin_pcie_parse_port(struct kirin_pcie *pcie,
 			pcie->num_slots++;
 			if (pcie->num_slots > MAX_PCI_SLOTS) {
 				dev_err(dev, "Too many PCI slots!\n");
-				return -EINVAL;
+				ret = -EINVAL;
+				goto put_node;
 			}
 
 			ret = of_pci_get_devfn(child);
@@ -446,6 +447,7 @@ static int kirin_pcie_parse_port(struct kirin_pcie *pcie,
 	return 0;
 
 put_node:
+	of_node_put(parent);
 	of_node_put(child);
 	return ret;
 }
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-11-05 18:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-05  2:07 [PATCH v2] PCI: kirin: Fix of_node_put() issue in pcie-kirin Wan Jiabing
2021-11-05 18:59 ` Bjorn Helgaas

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.