linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH resend 0/1] net: sun4i-emac: Properly free resources on probe failure
@ 2015-10-20  8:42 Hans de Goede
  2015-10-20  8:42 ` [PATCH resend] net: sun4i-emac: Properly free resources on probe failure and remove Hans de Goede
  2015-10-20 11:17 ` [PATCH resend 0/1] net: sun4i-emac: Properly free resources on probe failure David Miller
  0 siblings, 2 replies; 6+ messages in thread
From: Hans de Goede @ 2015-10-20  8:42 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Davem,

IIRC you said you would pick this up, but I'm not seeing it in net-next,
hence this resend.

Regards,

Hans

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

* [PATCH resend] net: sun4i-emac: Properly free resources on probe failure and remove
  2015-10-20  8:42 [PATCH resend 0/1] net: sun4i-emac: Properly free resources on probe failure Hans de Goede
@ 2015-10-20  8:42 ` Hans de Goede
  2015-10-20  9:12   ` Maxime Ripard
  2015-10-22  2:48   ` David Miller
  2015-10-20 11:17 ` [PATCH resend 0/1] net: sun4i-emac: Properly free resources on probe failure David Miller
  1 sibling, 2 replies; 6+ messages in thread
From: Hans de Goede @ 2015-10-20  8:42 UTC (permalink / raw)
  To: linux-arm-kernel

Fix sun4i-emac not releasing the following resources:
-iomapped memory not released on probe-failure nor on remove
-clock not getting disabled on probe-failure nor on remove
-sram not being released on remove

And while at it also add error checking to the clk_prepare_enable call
done on probe.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/net/ethernet/allwinner/sun4i-emac.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/allwinner/sun4i-emac.c b/drivers/net/ethernet/allwinner/sun4i-emac.c
index 48ce83e..8d50314 100644
--- a/drivers/net/ethernet/allwinner/sun4i-emac.c
+++ b/drivers/net/ethernet/allwinner/sun4i-emac.c
@@ -847,21 +847,25 @@ static int emac_probe(struct platform_device *pdev)
 	if (ndev->irq == -ENXIO) {
 		netdev_err(ndev, "No irq resource\n");
 		ret = ndev->irq;
-		goto out;
+		goto out_iounmap;
 	}
 
 	db->clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(db->clk)) {
 		ret = PTR_ERR(db->clk);
-		goto out;
+		goto out_iounmap;
 	}
 
-	clk_prepare_enable(db->clk);
+	ret = clk_prepare_enable(db->clk);
+	if (ret) {
+		dev_err(&pdev->dev, "Error couldn't enable clock (%d)\n", ret);
+		goto out_iounmap;
+	}
 
 	ret = sunxi_sram_claim(&pdev->dev);
 	if (ret) {
 		dev_err(&pdev->dev, "Error couldn't map SRAM to device\n");
-		goto out;
+		goto out_clk_disable_unprepare;
 	}
 
 	db->phy_node = of_parse_phandle(np, "phy", 0);
@@ -910,6 +914,10 @@ static int emac_probe(struct platform_device *pdev)
 
 out_release_sram:
 	sunxi_sram_release(&pdev->dev);
+out_clk_disable_unprepare:
+	clk_disable_unprepare(db->clk);
+out_iounmap:
+	iounmap(db->membase);
 out:
 	dev_err(db->dev, "not found (%d).\n", ret);
 
@@ -921,8 +929,12 @@ out:
 static int emac_remove(struct platform_device *pdev)
 {
 	struct net_device *ndev = platform_get_drvdata(pdev);
+	struct emac_board_info *db = netdev_priv(ndev);
 
 	unregister_netdev(ndev);
+	sunxi_sram_release(&pdev->dev);
+	clk_disable_unprepare(db->clk);
+	iounmap(db->membase);
 	free_netdev(ndev);
 
 	dev_dbg(&pdev->dev, "released and freed device\n");
-- 
2.5.0

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

* [PATCH resend] net: sun4i-emac: Properly free resources on probe failure and remove
  2015-10-20  8:42 ` [PATCH resend] net: sun4i-emac: Properly free resources on probe failure and remove Hans de Goede
@ 2015-10-20  9:12   ` Maxime Ripard
  2015-10-22  2:48   ` David Miller
  1 sibling, 0 replies; 6+ messages in thread
From: Maxime Ripard @ 2015-10-20  9:12 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Oct 20, 2015 at 10:42:24AM +0200, Hans de Goede wrote:
> Fix sun4i-emac not releasing the following resources:
> -iomapped memory not released on probe-failure nor on remove
> -clock not getting disabled on probe-failure nor on remove
> -sram not being released on remove
> 
> And while at it also add error checking to the clk_prepare_enable call
> done on probe.
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>

Thanks!
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20151020/b0583523/attachment.sig>

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

* [PATCH resend 0/1] net: sun4i-emac: Properly free resources on probe failure
  2015-10-20 11:17 ` [PATCH resend 0/1] net: sun4i-emac: Properly free resources on probe failure David Miller
@ 2015-10-20 11:10   ` Hans de Goede
  0 siblings, 0 replies; 6+ messages in thread
From: Hans de Goede @ 2015-10-20 11:10 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

On 20-10-15 13:17, David Miller wrote:
> From: Hans de Goede <hdegoede@redhat.com>
> Date: Tue, 20 Oct 2015 10:42:23 +0200
>>
>> IIRC you said you would pick this up, but I'm not seeing it in
>> net-next, hence this resend.
>
> If it's not in my tree, and it's not active on patchwork, you really
> have to resend your patches.
>
> Asking me to dig into submissions made some time in the past doesn't
> really work, sorry.

Right, that is why this mail was 0/1 it was just a cover-page,
there is a 2nd mail in the thread with the actual patch.

Regards,

Hans

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

* [PATCH resend 0/1] net: sun4i-emac: Properly free resources on probe failure
  2015-10-20  8:42 [PATCH resend 0/1] net: sun4i-emac: Properly free resources on probe failure Hans de Goede
  2015-10-20  8:42 ` [PATCH resend] net: sun4i-emac: Properly free resources on probe failure and remove Hans de Goede
@ 2015-10-20 11:17 ` David Miller
  2015-10-20 11:10   ` Hans de Goede
  1 sibling, 1 reply; 6+ messages in thread
From: David Miller @ 2015-10-20 11:17 UTC (permalink / raw)
  To: linux-arm-kernel

From: Hans de Goede <hdegoede@redhat.com>
Date: Tue, 20 Oct 2015 10:42:23 +0200
> 
> IIRC you said you would pick this up, but I'm not seeing it in
> net-next, hence this resend.

If it's not in my tree, and it's not active on patchwork, you really
have to resend your patches.

Asking me to dig into submissions made some time in the past doesn't
really work, sorry.
 

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

* [PATCH resend] net: sun4i-emac: Properly free resources on probe failure and remove
  2015-10-20  8:42 ` [PATCH resend] net: sun4i-emac: Properly free resources on probe failure and remove Hans de Goede
  2015-10-20  9:12   ` Maxime Ripard
@ 2015-10-22  2:48   ` David Miller
  1 sibling, 0 replies; 6+ messages in thread
From: David Miller @ 2015-10-22  2:48 UTC (permalink / raw)
  To: linux-arm-kernel

From: Hans de Goede <hdegoede@redhat.com>
Date: Tue, 20 Oct 2015 10:42:24 +0200

> Fix sun4i-emac not releasing the following resources:
> -iomapped memory not released on probe-failure nor on remove
> -clock not getting disabled on probe-failure nor on remove
> -sram not being released on remove
> 
> And while at it also add error checking to the clk_prepare_enable call
> done on probe.
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Applied.

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

end of thread, other threads:[~2015-10-22  2:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-20  8:42 [PATCH resend 0/1] net: sun4i-emac: Properly free resources on probe failure Hans de Goede
2015-10-20  8:42 ` [PATCH resend] net: sun4i-emac: Properly free resources on probe failure and remove Hans de Goede
2015-10-20  9:12   ` Maxime Ripard
2015-10-22  2:48   ` David Miller
2015-10-20 11:17 ` [PATCH resend 0/1] net: sun4i-emac: Properly free resources on probe failure David Miller
2015-10-20 11:10   ` Hans de Goede

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