net/ethoc: fix null dereference on error exit path
priv is assigned to NULL however some of the early error exit paths to label 'free' dereference priv, causing a null pointer dereference. Move the label 'free' to just the free_netdev statement, and add a new exit path 'free2' for the error cases were clk_disable_unprepare needs calling before the final free. Fixes issue found by CoverityScan, CID#113260 Signed-off-by: Colin Ian King <colin.king@canonical.com> Reviewed-by: Max Filippov <jcmvbkbc@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
fc14963f24
commit
bfa49cfc52
@@ -1195,7 +1195,7 @@ static int ethoc_probe(struct platform_device *pdev)
|
|||||||
priv->mdio = mdiobus_alloc();
|
priv->mdio = mdiobus_alloc();
|
||||||
if (!priv->mdio) {
|
if (!priv->mdio) {
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto free;
|
goto free2;
|
||||||
}
|
}
|
||||||
|
|
||||||
priv->mdio->name = "ethoc-mdio";
|
priv->mdio->name = "ethoc-mdio";
|
||||||
@@ -1208,7 +1208,7 @@ static int ethoc_probe(struct platform_device *pdev)
|
|||||||
ret = mdiobus_register(priv->mdio);
|
ret = mdiobus_register(priv->mdio);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(&netdev->dev, "failed to register MDIO bus\n");
|
dev_err(&netdev->dev, "failed to register MDIO bus\n");
|
||||||
goto free;
|
goto free2;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = ethoc_mdio_probe(netdev);
|
ret = ethoc_mdio_probe(netdev);
|
||||||
@@ -1241,9 +1241,10 @@ error2:
|
|||||||
error:
|
error:
|
||||||
mdiobus_unregister(priv->mdio);
|
mdiobus_unregister(priv->mdio);
|
||||||
mdiobus_free(priv->mdio);
|
mdiobus_free(priv->mdio);
|
||||||
free:
|
free2:
|
||||||
if (priv->clk)
|
if (priv->clk)
|
||||||
clk_disable_unprepare(priv->clk);
|
clk_disable_unprepare(priv->clk);
|
||||||
|
free:
|
||||||
free_netdev(netdev);
|
free_netdev(netdev);
|
||||||
out:
|
out:
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
Reference in New Issue
Block a user