]> git.baikalelectronics.ru Git - kernel.git/commit
mac80211: remove unnecessary NULL check
authorGustavo A. R. Silva <gustavo@embeddedor.com>
Tue, 4 Sep 2018 13:20:01 +0000 (08:20 -0500)
committerJohannes Berg <johannes.berg@intel.com>
Wed, 5 Sep 2018 08:15:48 +0000 (10:15 +0200)
commit3e85455595e7d216f2b10734b72f0a8741136119
tree75d8722bbe44f0d48c15672be048a6d4e2af3d3a
parentbe562b7284e79a9dcfc88378cc8551a56072565f
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>
net/mac80211/key.c