Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 619961f1 authored by Christophe JAILLET's avatar Christophe JAILLET Committed by Greg Kroah-Hartman
Browse files

net: allwinner: Fix some resources leak in the error handling path of the...


net: allwinner: Fix some resources leak in the error handling path of the probe and in the remove function

[ Upstream commit 322e53d1e2529ae9d501f5e0f20604a79b873aef ]

'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: 49220505 ("net: Add EMAC ethernet driver found on Allwinner A10 SoC's")
Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/20201214202117.146293-1-christophe.jaillet@wanadoo.fr


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent a558690b
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -827,13 +827,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);
@@ -890,6 +890,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:
@@ -908,6 +910,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);