diff options
author | Johannes Berg <johannes.berg@intel.com> | 2014-04-29 17:55:26 +0200 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2014-04-29 17:59:27 +0200 |
commit | 8c5bb1fad0bb9c29f7d817c1e2fdb052b76f04e9 (patch) | |
tree | 367302bae08e527e1ede890d8674dc9077b83e7e /net/mac80211/key.c | |
parent | 2fd0511556538a2d713e7a3d032c51cfe0117642 (diff) | |
download | lwn-8c5bb1fad0bb9c29f7d817c1e2fdb052b76f04e9.tar.gz lwn-8c5bb1fad0bb9c29f7d817c1e2fdb052b76f04e9.zip |
mac80211: remove BUG_ON usage
These BUG_ON statements should never trigger, but in the unlikely
event that somebody does manage don't stop everything but simply
exit the code path with an error.
Leave the one BUG_ON where changing it would result in a NULL
pointer dereference.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/mac80211/key.c')
-rw-r--r-- | net/mac80211/key.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/net/mac80211/key.c b/net/mac80211/key.c index 6ff65a1ebaa9..16d97f044a20 100644 --- a/net/mac80211/key.c +++ b/net/mac80211/key.c @@ -325,7 +325,8 @@ ieee80211_key_alloc(u32 cipher, int idx, size_t key_len, struct ieee80211_key *key; int i, j, err; - BUG_ON(idx < 0 || idx >= NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS); + if (WARN_ON(idx < 0 || idx >= NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS)) + return ERR_PTR(-EINVAL); key = kzalloc(sizeof(struct ieee80211_key) + key_len, GFP_KERNEL); if (!key) @@ -481,8 +482,8 @@ int ieee80211_key_link(struct ieee80211_key *key, int idx, ret; bool pairwise; - BUG_ON(!sdata); - BUG_ON(!key); + if (WARN_ON(!sdata || !key)) + return -EINVAL; pairwise = key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE; idx = key->conf.keyidx; |