phy: improve safety of fixed-phy MII register reading
authorRussell King <rmk+kernel@arm.linux.org.uk>
Thu, 23 Jun 2016 13:50:25 +0000 (14:50 +0100)
committerDavid S. Miller <davem@davemloft.net>
Mon, 27 Jun 2016 14:40:57 +0000 (10:40 -0400)
commitbf7afb29d545a6875fa44e17ddd23398e3dc30de
tree26af32aadf4e16da795e00c2d598bd8efbff593c
parent37688e3f53c327523caeccdb1ffb3830b4aea9a7
phy: improve safety of fixed-phy MII register reading

There is no prevention of a concurrent call to both fixed_mdio_read()
and fixed_phy_update_state(), which can result in the state being
modified while it's being inspected.  Fix this by using a seqcount
to detect modifications, and memcpy()ing the state.

We remain slightly naughty here, calling link_update() and updating
the link status within the read-side loop - which would need rework
of the design to change.

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/phy/fixed_phy.c