Skip to content

Commit

Permalink
net: dsa: Check return value of phy_connect_direct()
Browse files Browse the repository at this point in the history
BugLink: http://bugs.launchpad.net/bugs/1702863

[ Upstream commit 4078b76 ]

We need to check the return value of phy_connect_direct() in
dsa_slave_phy_connect() otherwise we may be continuing the
initialization of a slave network device with a PHY that already
attached somewhere else and which will soon be in error because the PHY
device is in error.

The conditions for such an error to occur are that we have a port of our
switch that is not disabled, and has the same port number as a PHY
address (say both 5) that can be probed using the DSA slave MII bus. We
end-up having this slave network device find a PHY at the same address
as our port number, and we try to attach to it.

A slave network (e.g: port 0) has already attached to our PHY device,
and we try to re-attach it with a different network device, but since we
ignore the error we would end-up initializating incorrect device
references by the time the slave network interface is opened.

The code has been (re)organized several times, making it hard to provide
an exact Fixes tag, this is a bugfix nonetheless.

Signed-off-by: Florian Fainelli <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
Signed-off-by: Stefan Bader <[email protected]>
Signed-off-by: Thadeu Lima de Souza Cascardo <[email protected]>
  • Loading branch information
ffainelli authored and ksacilotto committed Jul 19, 2017
1 parent d52d242 commit bcf13cb
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions net/dsa/slave.c
Original file line number Diff line number Diff line change
Expand Up @@ -1006,10 +1006,8 @@ static int dsa_slave_phy_connect(struct dsa_slave_priv *p,
/* Use already configured phy mode */
if (p->phy_interface == PHY_INTERFACE_MODE_NA)
p->phy_interface = p->phy->interface;
phy_connect_direct(slave_dev, p->phy, dsa_slave_adjust_link,
p->phy_interface);

return 0;
return phy_connect_direct(slave_dev, p->phy, dsa_slave_adjust_link,
p->phy_interface);
}

static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
Expand Down

0 comments on commit bcf13cb

Please sign in to comment.