PCI: kirin: Fix of_node_put() issue in pcie-kirin
PATCH v2 1/1 PCI: kirin: Fix of_node_put() issue in pcie-kirin
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.
--- drivers/pci/controller/dwc/pcie-kirin.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/pci/controller/dwc/pcie-kirin.c +3 -1
@@ -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; }
Signature · 1 line
2.20.1
Quoted 9 lines · Wan Jiabing
Fix following coccicheck warning:
./drivers/pci/controller/dwc/pcie-kirin.c:414:2-34: WARNING: Functionfor_each_available_child_of_nodeshould haveof_node_put()before return.Early exits from
for_each_available_child_of_nodeshould decrement the node reference counter. Replace return by goto here and add a missingof_node_putfor parent.Signed-off-by Wan Jiabing <[email protected]>
I had already squashed this into:
https://git.kernel.org/cgit/linux/kernel/git/helgaas/pci.git/commit/?id=b22dbbb24571
Quoted 29 lines
--- drivers/pci/controller/dwc/pcie-kirin.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/pci/controller/dwc/pcie-kirin.c +3
-1@@ -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; }Signature · 1 line
2.20.1