PCI: dwc: layerscape: Fix a leaked reference by adding missing of_node_put()
authorWen Yang <wen.yang99@zte.com.cn>
Wed, 27 Feb 2019 04:40:38 +0000 (12:40 +0800)
committerLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Mon, 1 Apr 2019 09:39:17 +0000 (10:39 +0100)
The call to of_parse_phandle() returns a node pointer with refcount
incremented thus it must be explicitly decremented after the last
usage.

Detected by coccinelle with the following warnings:
  ./drivers/pci/controller/dwc/pci-layerscape.c:204:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 198, but without a corresponding object release within this function.

Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Minghuan Lian <minghuan.Lian@nxp.com>
Cc: Mingkai Hu <mingkai.hu@nxp.com>
Cc: Roy Zang <roy.zang@nxp.com>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux-pci@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
drivers/pci/controller/dwc/pci-layerscape.c

index ce45bde29bf888d3bd4d80710105b8c5fd970274..3a5fa26d5e5675f9eabc7273598fc7c620106771 100644 (file)
@@ -201,6 +201,7 @@ static int ls_pcie_msi_host_init(struct pcie_port *pp)
                return -EINVAL;
        }
 
+       of_node_put(msi_node);
        return 0;
 }