Skip to content

Commit

Permalink
net: ti: icssg_prueth: Fix NULL pointer dereference in prueth_probe()
Browse files Browse the repository at this point in the history
In the prueth_probe() function, if one of the calls to emac_phy_connect()
fails due to of_phy_connect() returning NULL, then the subsequent call to
phy_attached_info() will dereference a NULL pointer.

Check the return code of emac_phy_connect and fail cleanly if there is an
error.

Fixes: 128d587 ("net: ti: icssg-prueth: Add ICSSG ethernet driver")
Cc: [email protected]
Signed-off-by: Romain Gantois <[email protected]>
Reviewed-by: Simon Horman <[email protected]>
Reviewed-by: MD Danish Anwar <[email protected]>
Signed-off-by: NipaLocal <nipa@local>
  • Loading branch information
rgantois authored and NipaLocal committed May 23, 2024
1 parent b2a622b commit 3df026e
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions drivers/net/ethernet/ti/icssg/icssg_prueth.c
Original file line number Diff line number Diff line change
Expand Up @@ -1039,7 +1039,12 @@ static int prueth_probe(struct platform_device *pdev)

prueth->registered_netdevs[PRUETH_MAC0] = prueth->emac[PRUETH_MAC0]->ndev;

emac_phy_connect(prueth->emac[PRUETH_MAC0]);
ret = emac_phy_connect(prueth->emac[PRUETH_MAC0]);
if (ret) {
dev_err(dev,
"can't connect to MII0 PHY, error -%d", ret);
goto netdev_unregister;
}
phy_attached_info(prueth->emac[PRUETH_MAC0]->ndev->phydev);
}

Expand All @@ -1051,7 +1056,12 @@ static int prueth_probe(struct platform_device *pdev)
}

prueth->registered_netdevs[PRUETH_MAC1] = prueth->emac[PRUETH_MAC1]->ndev;
emac_phy_connect(prueth->emac[PRUETH_MAC1]);
ret = emac_phy_connect(prueth->emac[PRUETH_MAC1]);
if (ret) {
dev_err(dev,
"can't connect to MII1 PHY, error %d", ret);
goto netdev_unregister;
}
phy_attached_info(prueth->emac[PRUETH_MAC1]->ndev->phydev);
}

Expand Down

0 comments on commit 3df026e

Please sign in to comment.