]> asedeno.scripts.mit.edu Git - linux.git/commit
net: dsa: Check return value of phy_connect_direct()
authorFlorian Fainelli <f.fainelli@gmail.com>
Sat, 21 Jan 2017 00:05:05 +0000 (16:05 -0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 23 Jan 2017 20:43:35 +0000 (15:43 -0500)
commit4078b76cac68e50ccf1f76a74e7d3d5788aec3fe
tree71925b730d481b6b906ab68b9a47d6439717ba21
parenteab127717a6af54401ba534790c793ec143cd1fc
net: dsa: Check return value of phy_connect_direct()

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 <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/dsa/slave.c