Commit fa3a419d authored by Wen Yang's avatar Wen Yang Committed by David S. Miller

net: xilinx: fix possible object reference leak

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/net/ethernet/xilinx/xilinx_axienet_main.c:1624:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 1569, but without a corresponding object release within this function.
Signed-off-by: default avatarWen Yang <wen.yang99@zte.com.cn>
Cc: Anirudha Sarangi <anirudh@xilinx.com>
Cc: John Linn <John.Linn@xilinx.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Michal Simek <michal.simek@xilinx.com>
Cc: netdev@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a7fb107b
...@@ -1575,12 +1575,14 @@ static int axienet_probe(struct platform_device *pdev) ...@@ -1575,12 +1575,14 @@ static int axienet_probe(struct platform_device *pdev)
ret = of_address_to_resource(np, 0, &dmares); ret = of_address_to_resource(np, 0, &dmares);
if (ret) { if (ret) {
dev_err(&pdev->dev, "unable to get DMA resource\n"); dev_err(&pdev->dev, "unable to get DMA resource\n");
of_node_put(np);
goto free_netdev; goto free_netdev;
} }
lp->dma_regs = devm_ioremap_resource(&pdev->dev, &dmares); lp->dma_regs = devm_ioremap_resource(&pdev->dev, &dmares);
if (IS_ERR(lp->dma_regs)) { if (IS_ERR(lp->dma_regs)) {
dev_err(&pdev->dev, "could not map DMA regs\n"); dev_err(&pdev->dev, "could not map DMA regs\n");
ret = PTR_ERR(lp->dma_regs); ret = PTR_ERR(lp->dma_regs);
of_node_put(np);
goto free_netdev; goto free_netdev;
} }
lp->rx_irq = irq_of_parse_and_map(np, 1); lp->rx_irq = irq_of_parse_and_map(np, 1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment