From 8115efbdc82acc935b54f0a849eb834129ea1fd0 Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Tue, 5 Feb 2013 10:08:35 +0200 Subject: [PATCH] iwlwifi: mvm: fix the keyidx assignment Fixes an issue that smatch pointed out: 1118 1119 key_flags = cpu_to_le16(keyconf->keyidx & STA_KEY_FLG_KEYID_MSK); ^^^^^^^^^^^^^^^ This is s8. ^^^^^^^^^^^^^^^^^^^^^ STA_KEY_FLG_KEYID_MSK is 0x300. The result after the bitwise AND is always zero because 0xff & 0x300. Reported-by: Dan Carpenter Signed-off-by: Emmanuel Grumbach Signed-off-by: Johannes Berg --- drivers/net/wireless/iwlwifi/mvm/sta.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/iwlwifi/mvm/sta.c b/drivers/net/wireless/iwlwifi/mvm/sta.c index 69603c3..8f8b66e 100644 --- a/drivers/net/wireless/iwlwifi/mvm/sta.c +++ b/drivers/net/wireless/iwlwifi/mvm/sta.c @@ -1116,7 +1116,8 @@ int iwl_mvm_remove_sta_key(struct iwl_mvm *mvm, if (WARN_ON_ONCE(mvm_sta->vif != vif)) return -EINVAL; - key_flags = cpu_to_le16(keyconf->keyidx & STA_KEY_FLG_KEYID_MSK); + key_flags = cpu_to_le16((keyconf->keyidx << STA_KEY_FLG_KEYID_POS) & + STA_KEY_FLG_KEYID_MSK); key_flags |= cpu_to_le16(STA_KEY_FLG_NO_ENC | STA_KEY_FLG_WEP_KEY_MAP); key_flags |= cpu_to_le16(STA_KEY_NOT_VALID); -- 2.7.4