1 --- a/drivers/net/wireless/ath/ath9k/common.c
2 +++ b/drivers/net/wireless/ath/ath9k/common.c
3 @@ -211,10 +211,14 @@ static int ath_reserve_key_cache_slot_tk
7 -static int ath_reserve_key_cache_slot(struct ath_common *common)
8 +static int ath_reserve_key_cache_slot(struct ath_common *common,
9 + enum ieee80211_key_alg alg)
13 + if (alg == ALG_TKIP)
14 + return ath_reserve_key_cache_slot_tkip(common);
16 /* First, try to find slots that would not be available for TKIP. */
17 if (common->splitmic) {
18 for (i = IEEE80211_WEP_NKID; i < common->keymax / 4; i++) {
19 @@ -283,6 +287,7 @@ int ath9k_cmn_key_config(struct ath_comm
20 struct ath_hw *ah = common->ah;
21 struct ath9k_keyval hk;
27 @@ -306,9 +311,23 @@ int ath9k_cmn_key_config(struct ath_comm
28 memcpy(hk.kv_val, key->key, key->keylen);
30 if (!(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) {
31 - /* For now, use the default keys for broadcast keys. This may
32 - * need to change with virtual interfaces. */
34 + switch (vif->type) {
35 + case NL80211_IFTYPE_AP:
36 + memcpy(gmac, vif->addr, ETH_ALEN);
39 + idx = ath_reserve_key_cache_slot(common, key->alg);
41 + case NL80211_IFTYPE_ADHOC:
42 + memcpy(gmac, sta->addr, ETH_ALEN);
45 + idx = ath_reserve_key_cache_slot(common, key->alg);
51 } else if (key->keyidx) {
54 @@ -325,14 +344,12 @@ int ath9k_cmn_key_config(struct ath_comm
58 - if (key->alg == ALG_TKIP)
59 - idx = ath_reserve_key_cache_slot_tkip(common);
61 - idx = ath_reserve_key_cache_slot(common);
63 - return -ENOSPC; /* no free key cache entries */
64 + idx = ath_reserve_key_cache_slot(common, key->alg);
68 + return -ENOSPC; /* no free key cache entries */
70 if (key->alg == ALG_TKIP)
71 ret = ath_setkey_tkip(common, idx, key->key, &hk, mac,
72 vif->type == NL80211_IFTYPE_AP);