net: dsa: Avoid null pointer when failing to connect to PHY
authorVladimir Oltean <olteanv@gmail.com>
Sat, 23 Mar 2019 23:24:07 +0000 (01:24 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 27 Jan 2020 13:50:34 +0000 (14:50 +0100)
commit7245f4562526b99d01a575a087a108047526763a
tree12677032c93c79a73d94d953739862f611baa07a
parenteb8f7fa7340bb7c3a515a992a9cf353f0c216716
net: dsa: Avoid null pointer when failing to connect to PHY

[ Upstream commit 6146dd453e235c487d85ae4dc6cc08978a1c890f ]

When phylink_of_phy_connect fails, dsa_slave_phy_setup tries to save the
day by connecting to an alternative PHY, none other than a PHY on the
switch's internal MDIO bus, at an address equal to the port's index.

However this does not take into consideration the scenario when the
switch that failed to probe an external PHY does not have an internal
MDIO bus at all.

Fixes: aab9c4067d23 ("net: dsa: Plug in PHYLINK support")
Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/dsa/slave.c