iavf: Fix race condition between iavf_shutdown and iavf_remove
authorSlawomir Laba <slawomirx.laba@intel.com>
Thu, 3 Nov 2022 13:00:03 +0000 (14:00 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 2 Dec 2022 16:41:04 +0000 (17:41 +0100)
commitecff08f3c469bfb25609df789f4149b10feec91c
treefc89e9bea81168b5ff0f99ccb571445521d30844
parent31147d4e907c732a5ce6d719ad4cc222654407e0
iavf: Fix race condition between iavf_shutdown and iavf_remove

[ Upstream commit a8417330f8a57275ed934293e832982b6d882713 ]

Fix a deadlock introduced by commit
974578017fc1 ("iavf: Add waiting so the port is initialized in remove")
due to race condition between iavf_shutdown and iavf_remove, where
iavf_remove stucks forever in while loop since iavf_shutdown already
set __IAVF_REMOVE adapter state.

Fix this by checking if the __IAVF_IN_REMOVE_TASK has already been
set and return if so.

Fixes: 974578017fc1 ("iavf: Add waiting so the port is initialized in remove")
Signed-off-by: Slawomir Laba <slawomirx.laba@intel.com>
Signed-off-by: Mateusz Palczewski <mateusz.palczewski@intel.com>
Tested-by: Marek Szlosek <marek.szlosek@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/intel/iavf/iavf_main.c