diff mbox

mac80211: fix NULL pointer dereference in ieee80211_key_alloc()

Message ID 1301160762-8409-1-git-send-email-ynezz@true.cz (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Petr Štetiar March 26, 2011, 5:32 p.m. UTC
None
diff mbox

Patch

diff --git a/net/mac80211/key.c b/net/mac80211/key.c
index 8c02469..8e49850 100644
--- a/net/mac80211/key.c
+++ b/net/mac80211/key.c
@@ -364,8 +364,11 @@  struct ieee80211_key *ieee80211_key_alloc(u32 cipher, int idx, size_t key_len,
 		}
 		break;
 	}
-	memcpy(key->conf.key, key_data, key_len);
-	INIT_LIST_HEAD(&key->list);
+
+	if (!IS_ERR(key)) {
+		memcpy(key->conf.key, key_data, key_len);
+		INIT_LIST_HEAD(&key->list);
+	}
 
 	return key;
 }