提交 53013c77 编写于 作者: F Florian Fainelli 提交者: David S. Miller

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: b31f65fb ("net: dsa: slave: Fix autoneg for phys on switch MDIO bus")
Reported-by: NBrian Norris <computersforpeace@gmail.com>
Signed-off-by: NAndrey Volkov <andrey.volkov@nexvision.fr>
Signed-off-by: NFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 70e71ca0
...@@ -555,6 +555,9 @@ static void dsa_slave_phy_setup(struct dsa_slave_priv *p, ...@@ -555,6 +555,9 @@ static void dsa_slave_phy_setup(struct dsa_slave_priv *p,
*/ */
if (!p->phy) { if (!p->phy) {
p->phy = ds->slave_mii_bus->phy_map[p->port]; p->phy = ds->slave_mii_bus->phy_map[p->port];
if (!p->phy)
return;
phy_connect_direct(slave_dev, p->phy, dsa_slave_adjust_link, phy_connect_direct(slave_dev, p->phy, dsa_slave_adjust_link,
p->phy_interface); p->phy_interface);
} else { } else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册