From: Johan Hovold Date: Thu, 8 May 2014 08:09:23 +0000 (+0200) Subject: net: cpsw: fix null dereference at probe X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e0fc51f96172f207cf4cb276e6a31a5d438f6b06;p=GitHub%2Fmt8127%2Fandroid_kernel_alcatel_ttab.git 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 Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c index d1a769f35f9d..b1ab3a4956a5 100644 --- a/drivers/net/ethernet/ti/cpsw.c +++ b/drivers/net/ethernet/ti/cpsw.c @@ -1547,6 +1547,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);