summaryrefslogtreecommitdiffstats
path: root/net/mac80211/key.c
diff options
context:
space:
mode:
authorGustavo A. R. Silva <gustavo@embeddedor.com>2018-09-04 08:20:01 -0500
committerJohannes Berg <johannes.berg@intel.com>2018-09-05 10:15:48 +0200
commit40b5a0f8c6c701dddd9b508b1d244203e89e9422 (patch)
tree75d8722bbe44f0d48c15672be048a6d4e2af3d3a /net/mac80211/key.c
parent9739fe29a207ffff55361a3047e7780ebddccdb2 (diff)
downloadlinux-40b5a0f8c6c701dddd9b508b1d244203e89e9422.tar.bz2
mac80211: remove unnecessary NULL check
Both old and new cannot be NULL at the same time, hence checking new when old is not NULL is unnecessary. Also, notice that new is being dereferenced before it is checked: idx = new->conf.keyidx; The above triggers a static code analysis warning. Address this by removing the NULL check on new and adding a code comment based on the following piece of code: 387 /* caller must provide at least one old/new */ 388 if (WARN_ON(!new && !old)) 389 return 0; Addresses-Coverity-ID: 1473176 ("Dereference before null check") Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/mac80211/key.c')
-rw-r--r--net/mac80211/key.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/net/mac80211/key.c b/net/mac80211/key.c
index d6eeace7b83a..4700718e010f 100644
--- a/net/mac80211/key.c
+++ b/net/mac80211/key.c
@@ -401,8 +401,9 @@ static int ieee80211_key_replace(struct ieee80211_sub_if_data *sdata,
* pairwise keys.*/
ret = ieee80211_hw_key_replace(old, new, pairwise);
} else {
+ /* new must be provided in case old is not */
idx = new->conf.keyidx;
- if (new && !new->local->wowlan)
+ if (!new->local->wowlan)
ret = ieee80211_key_enable_hw_accel(new);
else
ret = 0;