linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: allwinner: Fix some resources leak in the error handling path of the probe and in the remove function
@ 2020-12-14 20:21 Christophe JAILLET
  2020-12-15  8:56 ` Maxime Ripard
  2020-12-16 19:50 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 10+ messages in thread
From: Christophe JAILLET @ 2020-12-14 20:21 UTC (permalink / raw)
  To: davem, kuba, mripard, wens, jernej.skrabec, timur, song.bao.hua,
	f.fainelli, leon, hkallweit1, wangyunjian, sr
  Cc: linux-arm-kernel, netdev, linux-kernel, kernel-janitors,
	Christophe JAILLET

'irq_of_parse_and_map()' should be balanced by a corresponding
'irq_dispose_mapping()' call. Otherwise, there is some resources leaks.

Add such a call in the error handling path of the probe function and in the
remove function.

Fixes: 492205050d77 ("net: Add EMAC ethernet driver found on Allwinner A10 SoC's")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Please, carefully check the remove function, I'm not always confident by
the correct order when releasing resources. This is sometimes tricky.
---
 drivers/net/ethernet/allwinner/sun4i-emac.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/allwinner/sun4i-emac.c b/drivers/net/ethernet/allwinner/sun4i-emac.c
index 862ea44beea7..5ed80d9a6b9f 100644
--- a/drivers/net/ethernet/allwinner/sun4i-emac.c
+++ b/drivers/net/ethernet/allwinner/sun4i-emac.c
@@ -828,13 +828,13 @@ static int emac_probe(struct platform_device *pdev)
 	db->clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(db->clk)) {
 		ret = PTR_ERR(db->clk);
-		goto out_iounmap;
+		goto out_dispose_mapping;
 	}
 
 	ret = clk_prepare_enable(db->clk);
 	if (ret) {
 		dev_err(&pdev->dev, "Error couldn't enable clock (%d)\n", ret);
-		goto out_iounmap;
+		goto out_dispose_mapping;
 	}
 
 	ret = sunxi_sram_claim(&pdev->dev);
@@ -893,6 +893,8 @@ static int emac_probe(struct platform_device *pdev)
 	sunxi_sram_release(&pdev->dev);
 out_clk_disable_unprepare:
 	clk_disable_unprepare(db->clk);
+out_dispose_mapping:
+	irq_dispose_mapping(ndev->irq);
 out_iounmap:
 	iounmap(db->membase);
 out:
@@ -911,6 +913,7 @@ static int emac_remove(struct platform_device *pdev)
 	unregister_netdev(ndev);
 	sunxi_sram_release(&pdev->dev);
 	clk_disable_unprepare(db->clk);
+	irq_dispose_mapping(ndev->irq);
 	iounmap(db->membase);
 	free_netdev(ndev);
 
-- 
2.27.0


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

end of thread, other threads:[~2020-12-16 19:51 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-14 20:21 [PATCH] net: allwinner: Fix some resources leak in the error handling path of the probe and in the remove function Christophe JAILLET
2020-12-15  8:56 ` Maxime Ripard
2020-12-15  9:11   ` Dan Carpenter
2020-12-15 11:37     ` Maxime Ripard
2020-12-15 18:18       ` Christophe JAILLET
2020-12-15 19:08         ` Maxime Ripard
2020-12-15 19:35           ` Dan Carpenter
2020-12-15 20:15             ` Christophe JAILLET
     [not found]             ` <902018a7-19eb-cd15-5fde-6e0564fcd95c@wanadoo.fr>
2020-12-16  3:23               ` Chen-Yu Tsai
2020-12-16 19:50 ` patchwork-bot+netdevbpf

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).