]> git.baikalelectronics.ru Git - kernel.git/commit
net: dsa: handle non-existing PHYs on switch internal bus
authorFlorian Fainelli <f.fainelli@gmail.com>
Thu, 11 Dec 2014 20:49:15 +0000 (12:49 -0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 12 Dec 2014 01:58:50 +0000 (20:58 -0500)
commit548e2306694a084a91230e054ca790ffe9f66fd3
tree1213107ad4e164d2443e43845d7553d1bff07a65
parent7c7b812858475c6e1447e1e87904757aaae6e48b
net: dsa: handle non-existing PHYs on switch internal bus

In case there is no PHY at the designated address on the internal
switch, we would basically de-reference a null pointer here:

dsa_slave_phy_setup(...)
{
p->phy = ds->slave_mii_bus->phy_map[p->port];
phy_connect_direct(slave_dev, p->phy, dsa_slave_adjust_link,
      ^------

This can be triggered when the platform configuration (platform_data or
Device Tree) indicates there should be a PHY device at this address, but
the HW is non-responsive, such that we cannot attach a PHY device at
this specific location.

Fix this by checking the return value prior to calling
phy_connect_direct().

CC: Andrew Lunn <andrew@lunn.ch>
Fixes: 9af866c97195 ("net: dsa: slave: Fix autoneg for phys on switch MDIO bus")
Reported-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Andrey Volkov <andrey.volkov@nexvision.fr>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/dsa/slave.c