net: ravb: Fix error handling in ravb_probe
In ravb_probe(), we were missing a couple of things in the error
handling path:
* We must unregister the MDIO bus before freeing the corresponding
struct mii_dev instance to avoid the potential for use-after-free
bugs.
* We must free the resources acquired by clk_get_bulk() even if the
clocks have not yet been enabled.
Fixes: 8ae51b6f32
("net: ravb: Add Renesas Ethernet RAVB driver")
Signed-off-by: Paul Barker <paul.barker.ct@bp.renesas.com>
Reviewed-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
This commit is contained in:
@@ -592,7 +592,7 @@ static int ravb_probe(struct udevice *dev)
|
|||||||
|
|
||||||
ret = clk_get_bulk(dev, ð->clks);
|
ret = clk_get_bulk(dev, ð->clks);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto err_mdio_alloc;
|
goto err_clk_get;
|
||||||
|
|
||||||
mdiodev = mdio_alloc();
|
mdiodev = mdio_alloc();
|
||||||
if (!mdiodev) {
|
if (!mdiodev) {
|
||||||
@@ -614,23 +614,25 @@ static int ravb_probe(struct udevice *dev)
|
|||||||
/* Bring up PHY */
|
/* Bring up PHY */
|
||||||
ret = clk_enable_bulk(ð->clks);
|
ret = clk_enable_bulk(ð->clks);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err_mdio_register;
|
goto err_clk_enable;
|
||||||
|
|
||||||
ret = ravb_reset(dev);
|
ret = ravb_reset(dev);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err_mdio_reset;
|
goto err_clk_enable;
|
||||||
|
|
||||||
ret = ravb_phy_config(dev);
|
ret = ravb_phy_config(dev);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err_mdio_reset;
|
goto err_clk_enable;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_mdio_reset:
|
err_clk_enable:
|
||||||
clk_release_bulk(ð->clks);
|
mdio_unregister(mdiodev);
|
||||||
err_mdio_register:
|
err_mdio_register:
|
||||||
mdio_free(mdiodev);
|
mdio_free(mdiodev);
|
||||||
err_mdio_alloc:
|
err_mdio_alloc:
|
||||||
|
clk_release_bulk(ð->clks);
|
||||||
|
err_clk_get:
|
||||||
unmap_physmem(eth->iobase, MAP_NOCACHE);
|
unmap_physmem(eth->iobase, MAP_NOCACHE);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user