diff options
author | Johannes Berg <johannes.berg@intel.com> | 2017-03-22 22:00:10 +0100 |
---|---|---|
committer | Luca Coelho <luciano.coelho@intel.com> | 2017-06-05 21:47:07 +0300 |
commit | d9954405758a0cbbe258d9b4d4dc12a06fa48a28 (patch) | |
tree | 8b3d36bdfa53d54807a02a5dac894bb8b172e358 | |
parent | ee48b72211f844a58a06819e9ccceee6acf04b2d (diff) | |
download | linux-d9954405758a0cbbe258d9b4d4dc12a06fa48a28.tar.bz2 |
iwlwifi: tt: move ucode_loaded check under mutex
The ucode_loaded check should be under the mutex, since it can
otherwise change state after we looked at it and before we got
the mutex. Fix that.
Fixes: 5c89e7bc557e ("iwlwifi: mvm: add registration to cooling device")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
-rw-r--r-- | drivers/net/wireless/intel/iwlwifi/mvm/tt.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/tt.c b/drivers/net/wireless/intel/iwlwifi/mvm/tt.c index f9cbd197246f..506d58104e1c 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/tt.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/tt.c @@ -790,11 +790,13 @@ static int iwl_mvm_tcool_set_cur_state(struct thermal_cooling_device *cdev, struct iwl_mvm *mvm = (struct iwl_mvm *)(cdev->devdata); int ret; - if (!mvm->ucode_loaded || !(mvm->cur_ucode == IWL_UCODE_REGULAR)) - return -EIO; - mutex_lock(&mvm->mutex); + if (!mvm->ucode_loaded || !(mvm->cur_ucode == IWL_UCODE_REGULAR)) { + ret = -EIO; + goto unlock; + } + if (new_state >= ARRAY_SIZE(iwl_mvm_cdev_budgets)) { ret = -EINVAL; goto unlock; |