All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] marvell: pxa168_eth: fix call balance of pep->clk handling routines
@ 2024-11-21 20:06 Vitalii Mordan
  2024-11-26 11:00 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Vitalii Mordan @ 2024-11-21 20:06 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: Vitalii Mordan, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Jacob Keller, Shannon Nelson, Sabrina Dubroca,
	netdev, linux-kernel, Fedor Pchelkin, Alexey Khoroshilov,
	Vadim Mutilin

If the clock pep->clk was not enabled in pxa168_eth_probe,
it should not be disabled in any path.

Conversely, if it was enabled in pxa168_eth_probe, it must be disabled
in all error paths to ensure proper cleanup.

Use the devm_clk_get_enabled helper function to ensure proper call balance
for pep->clk.

Found by Linux Verification Center (linuxtesting.org) with Klever.

Fixes: a49f37eed22b ("net: add Fast Ethernet driver for PXA168.")
Signed-off-by: Vitalii Mordan <mordan@ispras.ru>
---
 drivers/net/ethernet/marvell/pxa168_eth.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/marvell/pxa168_eth.c b/drivers/net/ethernet/marvell/pxa168_eth.c
index 1a59c952aa01..45f115e41857 100644
--- a/drivers/net/ethernet/marvell/pxa168_eth.c
+++ b/drivers/net/ethernet/marvell/pxa168_eth.c
@@ -1394,18 +1394,15 @@ static int pxa168_eth_probe(struct platform_device *pdev)
 
 	printk(KERN_NOTICE "PXA168 10/100 Ethernet Driver\n");
 
-	clk = devm_clk_get(&pdev->dev, NULL);
+	clk = devm_clk_get_enabled(&pdev->dev, NULL);
 	if (IS_ERR(clk)) {
-		dev_err(&pdev->dev, "Fast Ethernet failed to get clock\n");
+		dev_err(&pdev->dev, "Fast Ethernet failed to get and enable clock\n");
 		return -ENODEV;
 	}
-	clk_prepare_enable(clk);
 
 	dev = alloc_etherdev(sizeof(struct pxa168_eth_private));
-	if (!dev) {
-		err = -ENOMEM;
-		goto err_clk;
-	}
+	if (!dev)
+		return -ENOMEM;
 
 	platform_set_drvdata(pdev, dev);
 	pep = netdev_priv(dev);
@@ -1523,8 +1520,6 @@ static int pxa168_eth_probe(struct platform_device *pdev)
 	mdiobus_free(pep->smi_bus);
 err_netdev:
 	free_netdev(dev);
-err_clk:
-	clk_disable_unprepare(clk);
 	return err;
 }
 
@@ -1542,7 +1537,6 @@ static void pxa168_eth_remove(struct platform_device *pdev)
 	if (dev->phydev)
 		phy_disconnect(dev->phydev);
 
-	clk_disable_unprepare(pep->clk);
 	mdiobus_unregister(pep->smi_bus);
 	mdiobus_free(pep->smi_bus);
 	unregister_netdev(dev);
-- 
2.25.1


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

* Re: [PATCH net] marvell: pxa168_eth: fix call balance of pep->clk handling routines
  2024-11-21 20:06 [PATCH net] marvell: pxa168_eth: fix call balance of pep->clk handling routines Vitalii Mordan
@ 2024-11-26 11:00 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-11-26 11:00 UTC (permalink / raw)
  To: Vitalii Mordan
  Cc: andrew+netdev, davem, edumazet, kuba, pabeni, jacob.e.keller,
	shannon.nelson, sd, netdev, linux-kernel, pchelkin, khoroshilov,
	mutilin

Hello:

This patch was applied to netdev/net.git (main)
by Paolo Abeni <pabeni@redhat.com>:

On Thu, 21 Nov 2024 23:06:58 +0300 you wrote:
> If the clock pep->clk was not enabled in pxa168_eth_probe,
> it should not be disabled in any path.
> 
> Conversely, if it was enabled in pxa168_eth_probe, it must be disabled
> in all error paths to ensure proper cleanup.
> 
> Use the devm_clk_get_enabled helper function to ensure proper call balance
> for pep->clk.
> 
> [...]

Here is the summary with links:
  - [net] marvell: pxa168_eth: fix call balance of pep->clk handling routines
    https://git.kernel.org/netdev/net/c/b032ae57d4fe

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2024-11-26 11:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-21 20:06 [PATCH net] marvell: pxa168_eth: fix call balance of pep->clk handling routines Vitalii Mordan
2024-11-26 11:00 ` patchwork-bot+netdevbpf

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.