net, phy, cpsw: fix NULL pointer deference
if phy_connect() did not find a phy, phydev is NULL and following code in cpsw_phy_init() crashes. Fix this. Signed-off-by: Heiko Schocher <hs@denx.de> Cc: Joe Hershberger <joe.hershberger@gmail.com> Cc: Mugunthan V N <mugunthanvnm@ti.com> Cc: Tom Rini <trini@ti.com> Acked-by: Mugunthan V N <mugunthanvnm@ti.com>
This commit is contained in:
parent
e22cc0cf13
commit
93ff255298
|
@ -568,9 +568,14 @@ static void cpsw_set_slave_mac(struct cpsw_slave *slave,
|
||||||
static void cpsw_slave_update_link(struct cpsw_slave *slave,
|
static void cpsw_slave_update_link(struct cpsw_slave *slave,
|
||||||
struct cpsw_priv *priv, int *link)
|
struct cpsw_priv *priv, int *link)
|
||||||
{
|
{
|
||||||
struct phy_device *phy = priv->phydev;
|
struct phy_device *phy;
|
||||||
u32 mac_control = 0;
|
u32 mac_control = 0;
|
||||||
|
|
||||||
|
phy = priv->phydev;
|
||||||
|
|
||||||
|
if (!phy)
|
||||||
|
return;
|
||||||
|
|
||||||
phy_startup(phy);
|
phy_startup(phy);
|
||||||
*link = phy->link;
|
*link = phy->link;
|
||||||
|
|
||||||
|
@ -947,6 +952,9 @@ static int cpsw_phy_init(struct eth_device *dev, struct cpsw_slave *slave)
|
||||||
dev,
|
dev,
|
||||||
slave->data->phy_if);
|
slave->data->phy_if);
|
||||||
|
|
||||||
|
if (!phydev)
|
||||||
|
return -1;
|
||||||
|
|
||||||
phydev->supported &= supported;
|
phydev->supported &= supported;
|
||||||
phydev->advertising = phydev->supported;
|
phydev->advertising = phydev->supported;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue