summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohan Hovold <jhovold@gmail.com>2014-05-08 10:09:23 +0200
committerJiri Slaby <jslaby@suse.cz>2014-07-02 12:06:02 +0200
commit1485b05f2a2ff688d94e5e0196133c020efa861e (patch)
treed2dbc9020f608ae5dfc4ca0437f9c4d1f0cb569d
parent4c9b5ae9bc67a79ec13a9ea29a0e020cd6cd0855 (diff)
downloadlwn-1485b05f2a2ff688d94e5e0196133c020efa861e.tar.gz
lwn-1485b05f2a2ff688d94e5e0196133c020efa861e.zip
net: cpsw: fix null dereference at probe
commit 6954cc1f238199e971ec905c5cc87120806ac981 upstream. Fix null-pointer dereference at probe when the mdio platform device is missing (e.g. when it has been disabled in DT). Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
-rw-r--r--drivers/net/ethernet/ti/cpsw.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index cc3ce557e4aa..498e808391a9 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -1797,6 +1797,10 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
mdio_node = of_find_node_by_phandle(be32_to_cpup(parp));
phyid = be32_to_cpup(parp+1);
mdio = of_find_device_by_node(mdio_node);
+ if (!mdio) {
+ pr_err("Missing mdio platform device\n");
+ return -EINVAL;
+ }
snprintf(slave_data->phy_id, sizeof(slave_data->phy_id),
PHY_ID_FMT, mdio->name, phyid);