marvell: pxa168_eth: fix call balance of pep->clk handling routines
[ Upstream commit b032ae57d4fe2b2445e3bc190db6fcaa8c102f68 ] 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> Link: https://patch.msgid.link/20241121200658.2203871-1-mordan@ispras.ru Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
3029950cca
commit
7f4f2553cf
1 changed files with 4 additions and 10 deletions
|
@ -1396,18 +1396,15 @@ static int pxa168_eth_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
printk(KERN_NOTICE "PXA168 10/100 Ethernet Driver\n");
|
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)) {
|
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;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
clk_prepare_enable(clk);
|
|
||||||
|
|
||||||
dev = alloc_etherdev(sizeof(struct pxa168_eth_private));
|
dev = alloc_etherdev(sizeof(struct pxa168_eth_private));
|
||||||
if (!dev) {
|
if (!dev)
|
||||||
err = -ENOMEM;
|
return -ENOMEM;
|
||||||
goto err_clk;
|
|
||||||
}
|
|
||||||
|
|
||||||
platform_set_drvdata(pdev, dev);
|
platform_set_drvdata(pdev, dev);
|
||||||
pep = netdev_priv(dev);
|
pep = netdev_priv(dev);
|
||||||
|
@ -1518,8 +1515,6 @@ err_free_mdio:
|
||||||
mdiobus_free(pep->smi_bus);
|
mdiobus_free(pep->smi_bus);
|
||||||
err_netdev:
|
err_netdev:
|
||||||
free_netdev(dev);
|
free_netdev(dev);
|
||||||
err_clk:
|
|
||||||
clk_disable_unprepare(clk);
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1536,7 +1531,6 @@ static int pxa168_eth_remove(struct platform_device *pdev)
|
||||||
if (dev->phydev)
|
if (dev->phydev)
|
||||||
phy_disconnect(dev->phydev);
|
phy_disconnect(dev->phydev);
|
||||||
|
|
||||||
clk_disable_unprepare(pep->clk);
|
|
||||||
mdiobus_unregister(pep->smi_bus);
|
mdiobus_unregister(pep->smi_bus);
|
||||||
mdiobus_free(pep->smi_bus);
|
mdiobus_free(pep->smi_bus);
|
||||||
cancel_work_sync(&pep->tx_timeout_task);
|
cancel_work_sync(&pep->tx_timeout_task);
|
||||||
|
|
Loading…
Add table
Reference in a new issue