]> git.itanic.dy.fi Git - linux-stable/commit
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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 26 Sep 2018 06:35:10 +0000 (08:35 +0200)
commit30eee1c68c52a02ec54730bfbe3ba4e3ff3a7d6e
tree6bc71667cbe6e1cfa68c078cd059562c80232423
parent24328b80de178d4ece8175481349ae33ba3ca65f
drivers: net: cpsw: fix segfault in case of bad phy-handle

commit d733f7542ad47cf73e033c90cf55158587e1d060 upstream.

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>
[SZ Lin (林上智): Tweak the patch to use original print function of dev_info()]
Signed-off-by: SZ Lin (林上智) <sz.lin@moxa.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/ti/cpsw.c