mac80211: fix TKIP races, make API easier to use
[pandora-kernel.git] / net / mac80211 / wpa.c
index d91c1a2..4ded2ae 100644 (file)
@@ -171,6 +171,7 @@ static int tkip_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb)
        struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
        struct ieee80211_key *key = tx->key;
        struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
+       unsigned long flags;
        unsigned int hdrlen;
        int len, tail;
        u8 *pos;
@@ -198,11 +199,12 @@ static int tkip_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb)
        pos += hdrlen;
 
        /* Increase IV for the frame */
+       spin_lock_irqsave(&key->u.tkip.txlock, flags);
        key->u.tkip.tx.iv16++;
        if (key->u.tkip.tx.iv16 == 0)
                key->u.tkip.tx.iv32++;
-
-       pos = ieee80211_tkip_add_iv(pos, key, key->u.tkip.tx.iv16);
+       pos = ieee80211_tkip_add_iv(pos, key);
+       spin_unlock_irqrestore(&key->u.tkip.txlock, flags);
 
        /* hwaccel - with software IV */
        if (info->control.hw_key)
@@ -211,9 +213,8 @@ static int tkip_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb)
        /* Add room for ICV */
        skb_put(skb, TKIP_ICV_LEN);
 
-       hdr = (struct ieee80211_hdr *) skb->data;
        return ieee80211_tkip_encrypt_data(tx->local->wep_tx_tfm,
-                                          key, pos, len, hdr->addr2);
+                                          key, skb, pos, len);
 }