]> Pileus Git - ~andy/linux/commitdiff
mac80211: verify ieee80211_key_replace() arguments
authorJohannes Berg <johannes.berg@intel.com>
Tue, 29 Oct 2013 09:00:08 +0000 (10:00 +0100)
committerJohannes Berg <johannes.berg@intel.com>
Mon, 25 Nov 2013 19:50:44 +0000 (20:50 +0100)
There's no code calling ieee80211_key_replace() with both
arguments NULL and it wouldn't make sense, but in the
interest of maintainability add a warning for it. As a
side effect, this also shuts up a smatch warning.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/key.c

index 3e51dd7d98b34aad114e6b927beae8e4ecdde9fb..ab8468047200530ca02322baec9f0189af4f2b34 100644 (file)
@@ -260,6 +260,10 @@ static void ieee80211_key_replace(struct ieee80211_sub_if_data *sdata,
        int idx;
        bool defunikey, defmultikey, defmgmtkey;
 
+       /* caller must provide at least one old/new */
+       if (WARN_ON(!new && !old))
+               return;
+
        if (new)
                list_add_tail(&new->list, &sdata->key_list);