linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] net: xilinx: fix possible object reference leak
@ 2019-03-22  3:04 Wen Yang
  2019-03-24  1:21 ` David Miller
  2019-04-05  7:54 ` Markus Elfring
  0 siblings, 2 replies; 5+ messages in thread
From: Wen Yang @ 2019-03-22  3:04 UTC (permalink / raw)
  To: linux-kernel
  Cc: wang.yi59, netdev, Michal Simek, Wen Yang, Anirudha Sarangi,
	John Linn, David S. Miller, linux-arm-kernel

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: Wen 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
---
 drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
index ec7e7ec..4041c75 100644
--- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
@@ -1575,12 +1575,14 @@ static int axienet_probe(struct platform_device *pdev)
 	ret = of_address_to_resource(np, 0, &dmares);
 	if (ret) {
 		dev_err(&pdev->dev, "unable to get DMA resource\n");
+		of_node_put(np);
 		goto free_netdev;
 	}
 	lp->dma_regs = devm_ioremap_resource(&pdev->dev, &dmares);
 	if (IS_ERR(lp->dma_regs)) {
 		dev_err(&pdev->dev, "could not map DMA regs\n");
 		ret = PTR_ERR(lp->dma_regs);
+		of_node_put(np);
 		goto free_netdev;
 	}
 	lp->rx_irq = irq_of_parse_and_map(np, 1);
-- 
2.9.5


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 1/3] net: xilinx: fix possible object reference leak
  2019-03-22  3:04 [PATCH 1/3] net: xilinx: fix possible object reference leak Wen Yang
@ 2019-03-24  1:21 ` David Miller
  2019-04-05  7:54 ` Markus Elfring
  1 sibling, 0 replies; 5+ messages in thread
From: David Miller @ 2019-03-24  1:21 UTC (permalink / raw)
  To: wen.yang99
  Cc: wang.yi59, netdev, michal.simek, linux-kernel, anirudh,
	John.Linn, linux-arm-kernel

From: Wen Yang <wen.yang99@zte.com.cn>
Date: Fri, 22 Mar 2019 11:04:07 +0800

> 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: Wen Yang <wen.yang99@zte.com.cn>

Applied.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 1/3] net: xilinx: fix possible object reference leak
  2019-03-22  3:04 [PATCH 1/3] net: xilinx: fix possible object reference leak Wen Yang
  2019-03-24  1:21 ` David Miller
@ 2019-04-05  7:54 ` Markus Elfring
  2019-04-05  8:13   ` Dan Carpenter
  1 sibling, 1 reply; 5+ messages in thread
From: Markus Elfring @ 2019-04-05  7:54 UTC (permalink / raw)
  To: Wen Yang, David S. Miller, netdev, kernel-janitors
  Cc: Yi Wang, Michal Simek, linux-kernel, Anirudha Sarangi, John Linn,
	linux-arm-kernel

> @@ -1575,12 +1575,14 @@  static int axienet_probe(struct platform_device *pdev)
>  	ret = of_address_to_resource(np, 0, &dmares);
>  	if (ret) {
>  		dev_err(&pdev->dev, "unable to get DMA resource\n");
> +		of_node_put(np);
>  		goto free_netdev;
>  	}
>  	lp->dma_regs = devm_ioremap_resource(&pdev->dev, &dmares);
>  	if (IS_ERR(lp->dma_regs)) {
>  		dev_err(&pdev->dev, "could not map DMA regs\n");
>  		ret = PTR_ERR(lp->dma_regs);
> +		of_node_put(np);
>  		goto free_netdev;
>  	}

How do you think about to move these put calls to an additional
jump target for the desired exception handling?

https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/net/ethernet/xilinx/xilinx_axienet_main.c?id=fa3a419d2f674b431d38748cb58fb7da17ee8949#n1621

Regards,
Markus

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 1/3] net: xilinx: fix possible object reference leak
  2019-04-05  7:54 ` Markus Elfring
@ 2019-04-05  8:13   ` Dan Carpenter
  2019-04-05  9:18     ` [1/3] " Markus Elfring
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2019-04-05  8:13 UTC (permalink / raw)
  To: Markus Elfring
  Cc: Yi Wang, Michal Simek, netdev, kernel-janitors, linux-kernel,
	David S. Miller, Anirudha Sarangi, John Linn, Wen Yang,
	linux-arm-kernel

Hi Markus,

Please don't add kernel-janitors to the CC list in the middle of the
conversation.  Netdev people can review their own code.  We don't have a
copy of the patch your discussing and it's not even clear who you're
responding to.

regards,
dan carpenter


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [1/3] net: xilinx: fix possible object reference leak
  2019-04-05  8:13   ` Dan Carpenter
@ 2019-04-05  9:18     ` Markus Elfring
  0 siblings, 0 replies; 5+ messages in thread
From: Markus Elfring @ 2019-04-05  9:18 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Yi Wang, Michal Simek, netdev, linux-kernel, David S. Miller,
	Anirudha Sarangi, John Linn, Wen Yang, linux-arm-kernel

> We don't have a copy of the patch your discussing

I find this information inappropriate because I quoted
a questionable change.

Will any contributors get interested in another update for
the implementation of the function “axienet_probe”?
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/net/ethernet/xilinx/xilinx_axienet_main.c?id=fa3a419d2f674b431d38748cb58fb7da17ee8949#n1576


> and it's not even clear who you're responding to.

I wonder about this feedback.

Regards,
Markus

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2019-04-05  9:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-22  3:04 [PATCH 1/3] net: xilinx: fix possible object reference leak Wen Yang
2019-03-24  1:21 ` David Miller
2019-04-05  7:54 ` Markus Elfring
2019-04-05  8:13   ` Dan Carpenter
2019-04-05  9:18     ` [1/3] " Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).