aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/key.c
diff options
context:
space:
mode:
authorBen Hutchings <ben@decadent.org.uk>2010-08-01 12:37:03 -0400
committerJohn W. Linville <linville@tuxdriver.com>2010-08-16 15:26:38 -0400
commit1ac62ba7c985109868a18d959986425148481f47 (patch)
tree35504e08e075978f7dcdd791bdfa2fab132b778a /net/mac80211/key.c
parenta85d7cca1204f2dba86d2f61693f0fe8c48f0fa5 (diff)
mac80211: Don't squash error codes in key setup functions
ieee80211_add_key() currently returns -ENOMEM in case of any error, including a missing crypto algorithm. Change ieee80211_key_alloc() and ieee80211_aes_{key_setup_encrypt,cmac_key_setup}() to encode errors with ERR_PTR() rather than returning NULL, and change ieee80211_add_key() accordingly. Compile-tested only. Reported-by: Marcin Owsiany <porridge@debian.org> Signed-off-by: Ben Hutchings <ben@decadent.org.uk> Acked-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211/key.c')
-rw-r--r--net/mac80211/key.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/net/mac80211/key.c b/net/mac80211/key.c
index 1b9d87ed143a..d6dbc8ea4ead 100644
--- a/net/mac80211/key.c
+++ b/net/mac80211/key.c
@@ -234,13 +234,13 @@ struct ieee80211_key *ieee80211_key_alloc(enum ieee80211_key_alg alg,
234 size_t seq_len, const u8 *seq) 234 size_t seq_len, const u8 *seq)
235{ 235{
236 struct ieee80211_key *key; 236 struct ieee80211_key *key;
237 int i, j; 237 int i, j, err;
238 238
239 BUG_ON(idx < 0 || idx >= NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS); 239 BUG_ON(idx < 0 || idx >= NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS);
240 240
241 key = kzalloc(sizeof(struct ieee80211_key) + key_len, GFP_KERNEL); 241 key = kzalloc(sizeof(struct ieee80211_key) + key_len, GFP_KERNEL);
242 if (!key) 242 if (!key)
243 return NULL; 243 return ERR_PTR(-ENOMEM);
244 244
245 /* 245 /*
246 * Default to software encryption; we'll later upload the 246 * Default to software encryption; we'll later upload the
@@ -296,9 +296,10 @@ struct ieee80211_key *ieee80211_key_alloc(enum ieee80211_key_alg alg,
296 * it does not need to be initialized for every packet. 296 * it does not need to be initialized for every packet.
297 */ 297 */
298 key->u.ccmp.tfm = ieee80211_aes_key_setup_encrypt(key_data); 298 key->u.ccmp.tfm = ieee80211_aes_key_setup_encrypt(key_data);
299 if (!key->u.ccmp.tfm) { 299 if (IS_ERR(key->u.ccmp.tfm)) {
300 err = PTR_ERR(key->u.ccmp.tfm);
300 kfree(key); 301 kfree(key);
301 return NULL; 302 key = ERR_PTR(err);
302 } 303 }
303 } 304 }
304 305
@@ -309,9 +310,10 @@ struct ieee80211_key *ieee80211_key_alloc(enum ieee80211_key_alg alg,
309 */ 310 */
310 key->u.aes_cmac.tfm = 311 key->u.aes_cmac.tfm =
311 ieee80211_aes_cmac_key_setup(key_data); 312 ieee80211_aes_cmac_key_setup(key_data);
312 if (!key->u.aes_cmac.tfm) { 313 if (IS_ERR(key->u.aes_cmac.tfm)) {
314 err = PTR_ERR(key->u.aes_cmac.tfm);
313 kfree(key); 315 kfree(key);
314 return NULL; 316 key = ERR_PTR(err);
315 } 317 }
316 } 318 }
317 319