net: sfp: add mutex to prevent concurrent state checks
authorRobert Hancock <hancock@sedsystems.ca>
Fri, 7 Jun 2019 16:42:36 +0000 (10:42 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 31 Jul 2019 05:28:24 +0000 (07:28 +0200)
commit1ee7774527ab48d8a114bfae135bcee619ce9147
tree030d5edd1770591c718196fe11ce2b9aa73fba52
parent0dd8efba833c8ed26fbfec3c1d50f624e04ec9a0
net: sfp: add mutex to prevent concurrent state checks

[ Upstream commit 2158e856f56bb762ef90f3ec244d41a519826f75 ]

sfp_check_state can potentially be called by both a threaded IRQ handler
and delayed work. If it is concurrently called, it could result in
incorrect state management. Add a st_mutex to protect the state - this
lock gets taken outside of code that checks and handle state changes, and
the existing sm_mutex nests inside of it.

Suggested-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Robert Hancock <hancock@sedsystems.ca>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/phy/sfp.c