drivers: net: cpsw: fix segfault in case of bad phy-handle
authorDavid Rivshin <drivshin@allworx.com>
Thu, 28 Apr 2016 01:32:31 +0000 (21:32 -0400)
committerDavid S. Miller <davem@davemloft.net>
Thu, 28 Apr 2016 21:27:29 +0000 (17:27 -0400)
commitd733f7542ad47cf73e033c90cf55158587e1d060
tree552f4ff79dcecd32d50c614e7ed8e6c4f819524a
parent552165bcf7060b998b4a9b5b86110b6a5e04dfd9
drivers: net: cpsw: fix segfault in case of bad phy-handle

If an emac node has a phy-handle property that points to something
which is not a phy, then a segmentation fault will occur when the
interface is brought up. This is because while phy_connect() will
return ERR_PTR() on failure, of_phy_connect() will return NULL.
The common error check uses IS_ERR(), and so missed when
of_phy_connect() fails. The NULL pointer is then dereferenced.

Also, the common error message referenced slave->data->phy_id,
which would be empty in the case of phy-handle. Instead, use the
name of the device_node as a useful identifier. And in the phy_id
case add the error code for completeness.

Fixes: 9e42f715264f ("drivers: net: cpsw: add phy-handle parsing")
Signed-off-by: David Rivshin <drivshin@allworx.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/ti/cpsw.c
This page took 0.02546 seconds and 5 git commands to generate.