X-Git-Url: http://git.cascardo.eti.br/?a=blobdiff_plain;f=net%2Fwireless%2Fwext-compat.c;h=2b096c02eb8577835d1912f6cee9a35c66abfc4e;hb=8f7d99ba85d4d7118a6cf2d0ed9c2ff8e6528679;hp=7b97d43b27e124d961a3eb5892fa2d334fead1ce;hpb=8564e38206de2ff005a27c8d7c2ce3869a44f0dd;p=cascardo%2Flinux.git diff --git a/net/wireless/wext-compat.c b/net/wireless/wext-compat.c index 7b97d43b27e1..2b096c02eb85 100644 --- a/net/wireless/wext-compat.c +++ b/net/wireless/wext-compat.c @@ -406,6 +406,10 @@ static int __cfg80211_set_encryption(struct cfg80211_registered_device *rdev, if (pairwise && !addr) return -EINVAL; + /* + * In many cases we won't actually need this, but it's better + * to do it first in case the allocation fails. Don't use wext. + */ if (!wdev->wext.keys) { wdev->wext.keys = kzalloc(sizeof(*wdev->wext.keys), GFP_KERNEL); @@ -493,7 +497,13 @@ static int __cfg80211_set_encryption(struct cfg80211_registered_device *rdev, if (err) return err; - if (!addr) { + /* + * We only need to store WEP keys, since they're the only keys that + * can be be set before a connection is established and persist after + * disconnecting. + */ + if (!addr && (params->cipher == WLAN_CIPHER_SUITE_WEP40 || + params->cipher == WLAN_CIPHER_SUITE_WEP104)) { wdev->wext.keys->params[idx] = *params; memcpy(wdev->wext.keys->data[idx], params->key, params->key_len);