summaryrefslogtreecommitdiff
path: root/drivers/net
diff options
context:
space:
mode:
authorHeiko Schocher <hs@denx.de>2013-09-05 11:50:41 +0200
committerTom Rini <trini@ti.com>2013-09-20 16:57:40 -0400
commit93ff25529898b931b5000c6e9ec9d7325f2ec414 (patch)
treee809dff00799bd968e0ec0f5de3b7a60ad4a6927 /drivers/net
parente22cc0cf137149bea3a06bb29ffe06e82d8edb84 (diff)
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>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/cpsw.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/net/cpsw.c b/drivers/net/cpsw.c
index 9bab71a212..39240d9662 100644
--- a/drivers/net/cpsw.c
+++ b/drivers/net/cpsw.c
@@ -568,9 +568,14 @@ static void cpsw_set_slave_mac(struct cpsw_slave *slave,
static void cpsw_slave_update_link(struct cpsw_slave *slave,
struct cpsw_priv *priv, int *link)
{
- struct phy_device *phy = priv->phydev;
+ struct phy_device *phy;
u32 mac_control = 0;
+ phy = priv->phydev;
+
+ if (!phy)
+ return;
+
phy_startup(phy);
*link = phy->link;
@@ -947,6 +952,9 @@ static int cpsw_phy_init(struct eth_device *dev, struct cpsw_slave *slave)
dev,
slave->data->phy_if);
+ if (!phydev)
+ return -1;
+
phydev->supported &= supported;
phydev->advertising = phydev->supported;