All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: davem@davemloft.net, kuba@kernel.org, mripard@kernel.org,
	wens@csie.org, jernej.skrabec@siol.net, timur@kernel.org,
	song.bao.hua@hisilicon.com, f.fainelli@gmail.com,
	leon@kernel.org, hkallweit1@gmail.com, wangyunjian@huawei.com,
	sr@denx.de
Cc: linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
	Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Subject: [PATCH] net: allwinner: Fix some resources leak in the error handling path of the probe and in the remove function
Date: Mon, 14 Dec 2020 21:21:17 +0100	[thread overview]
Message-ID: <20201214202117.146293-1-christophe.jaillet@wanadoo.fr> (raw)

'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


WARNING: multiple messages have this Message-ID (diff)
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: davem@davemloft.net, kuba@kernel.org, mripard@kernel.org,
	wens@csie.org, jernej.skrabec@siol.net, timur@kernel.org,
	song.bao.hua@hisilicon.com, f.fainelli@gmail.com,
	leon@kernel.org, hkallweit1@gmail.com, wangyunjian@huawei.com,
	sr@denx.de
Cc: netdev@vger.kernel.org,
	Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
	kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Subject: [PATCH] net: allwinner: Fix some resources leak in the error handling path of the probe and in the r
Date: Mon, 14 Dec 2020 20:21:17 +0000	[thread overview]
Message-ID: <20201214202117.146293-1-christophe.jaillet@wanadoo.fr> (raw)

'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

WARNING: multiple messages have this Message-ID (diff)
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: davem@davemloft.net, kuba@kernel.org, mripard@kernel.org,
	wens@csie.org, jernej.skrabec@siol.net, timur@kernel.org,
	song.bao.hua@hisilicon.com, f.fainelli@gmail.com,
	leon@kernel.org, hkallweit1@gmail.com, wangyunjian@huawei.com,
	sr@denx.de
Cc: netdev@vger.kernel.org,
	Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
	kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Subject: [PATCH] net: allwinner: Fix some resources leak in the error handling path of the probe and in the remove function
Date: Mon, 14 Dec 2020 21:21:17 +0100	[thread overview]
Message-ID: <20201214202117.146293-1-christophe.jaillet@wanadoo.fr> (raw)

'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


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

             reply	other threads:[~2020-12-14 20:23 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-14 20:21 Christophe JAILLET [this message]
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-14 20:21 ` [PATCH] net: allwinner: Fix some resources leak in the error handling path of the probe and in the r Christophe JAILLET
2020-12-15  8:56 ` [PATCH] net: allwinner: Fix some resources leak in the error handling path of the probe and in the remove function Maxime Ripard
2020-12-15  8:56   ` Maxime Ripard
2020-12-15  8:56   ` [PATCH] net: allwinner: Fix some resources leak in the error handling path of the probe and in t Maxime Ripard
2020-12-15  9:11   ` [PATCH] net: allwinner: Fix some resources leak in the error handling path of the probe and in the remove function Dan Carpenter
2020-12-15  9:11     ` Dan Carpenter
2020-12-15  9:11     ` [PATCH] net: allwinner: Fix some resources leak in the error handling path of the probe and in t Dan Carpenter
2020-12-15 11:37     ` [PATCH] net: allwinner: Fix some resources leak in the error handling path of the probe and in the remove function Maxime Ripard
2020-12-15 11:37       ` Maxime Ripard
2020-12-15 11:37       ` [PATCH] net: allwinner: Fix some resources leak in the error handling path of the probe and in t Maxime Ripard
2020-12-15 18:18       ` [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 18:18         ` Christophe JAILLET
2020-12-15 18:18         ` [PATCH] net: allwinner: Fix some resources leak in the error handling path of the probe and in t Christophe JAILLET
2020-12-15 19:08         ` [PATCH] net: allwinner: Fix some resources leak in the error handling path of the probe and in the remove function Maxime Ripard
2020-12-15 19:08           ` Maxime Ripard
2020-12-15 19:08           ` [PATCH] net: allwinner: Fix some resources leak in the error handling path of the probe and in t Maxime Ripard
2020-12-15 19:35           ` [PATCH] net: allwinner: Fix some resources leak in the error handling path of the probe and in the remove function Dan Carpenter
2020-12-15 19:35             ` Dan Carpenter
2020-12-15 19:35             ` [PATCH] net: allwinner: Fix some resources leak in the error handling path of the probe and in t Dan Carpenter
2020-12-15 20:15             ` [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 21:08               ` Markus Elfring
2020-12-16  3:23               ` [PATCH] " Chen-Yu Tsai
2020-12-16  3:23                 ` Chen-Yu Tsai
2020-12-16  3:23                 ` [PATCH] net: allwinner: Fix some resources leak in the error handling path of the probe and in t Chen-Yu Tsai
2020-12-15 20:15             ` [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 20:15               ` Christophe JAILLET
2020-12-15 20:15               ` [PATCH] net: allwinner: Fix some resources leak in the error handling path of the probe and in t Christophe JAILLET
2020-12-16 19:50 ` [PATCH] net: allwinner: Fix some resources leak in the error handling path of the probe and in the remove function patchwork-bot+netdevbpf
2020-12-16 19:50   ` patchwork-bot+netdevbpf
2020-12-16 19:50   ` [PATCH] net: allwinner: Fix some resources leak in the error handling path of the probe and in t patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201214202117.146293-1-christophe.jaillet@wanadoo.fr \
    --to=christophe.jaillet@wanadoo.fr \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=hkallweit1@gmail.com \
    --cc=jernej.skrabec@siol.net \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mripard@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=song.bao.hua@hisilicon.com \
    --cc=sr@denx.de \
    --cc=timur@kernel.org \
    --cc=wangyunjian@huawei.com \
    --cc=wens@csie.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.