Skip to content

Commit 6954cc1

Browse files
jhovolddavem330
authored andcommitted
net: cpsw: fix null dereference at probe
Fix null-pointer dereference at probe when the mdio platform device is missing (e.g. when it has been disabled in DT). Cc: stable <[email protected]> # v3.8 Signed-off-by: Johan Hovold <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 59993f4 commit 6954cc1

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/net/ethernet/ti/cpsw.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1871,6 +1871,10 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
18711871
mdio_node = of_find_node_by_phandle(be32_to_cpup(parp));
18721872
phyid = be32_to_cpup(parp+1);
18731873
mdio = of_find_device_by_node(mdio_node);
1874+
if (!mdio) {
1875+
pr_err("Missing mdio platform device\n");
1876+
return -EINVAL;
1877+
}
18741878
snprintf(slave_data->phy_id, sizeof(slave_data->phy_id),
18751879
PHY_ID_FMT, mdio->name, phyid);
18761880

0 commit comments

Comments
 (0)