net: phy: fix race in genphy_update_link
authorHeiner Kallweit <hkallweit1@gmail.com>
Wed, 31 Jul 2019 21:05:10 +0000 (23:05 +0200)
committerDavid S. Miller <davem@davemloft.net>
Sat, 3 Aug 2019 01:16:04 +0000 (18:16 -0700)
commitaa6b1956158f1afc52761137620d4b3f8a058d24
treeae2e398a615a9348ca4833f94ac395bae875719c
parent2802d2cf24b1ca7ea4c54dde266ded6a16020eb5
net: phy: fix race in genphy_update_link

In phy_start_aneg() autoneg is started, and immediately after that
link and autoneg status are read. As reported in [0] it can happen that
at time of this read the PHY has reset the "aneg complete" bit but not
yet the "link up" bit, what can result in a false link-up detection.
To fix this don't report link as up if we're in aneg mode and PHY
doesn't signal "aneg complete".

[0] https://marc.info/?t=156413509900003&r=1&w=2

Fixes: 4950c2ba49cc ("net: phy: fix autoneg mismatch case in genphy_read_status")
Reported-by: liuyonglong <liuyonglong@huawei.com>
Tested-by: liuyonglong <liuyonglong@huawei.com>
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/phy/phy_device.c