mac80211: fix minor memleak on AP restart / warning on driver unload
[openwrt/openwrt.git] / package / kernel / mac80211 / patches / 334-mac80211-fix-purging-multicast-PS-buffer-queue.patch
1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Tue, 2 Aug 2016 11:11:13 +0200
3 Subject: [PATCH] mac80211: fix purging multicast PS buffer queue
4
5 The code currently assumes that buffered multicast PS frames don't have
6 a pending ACK frame for tx status reporting.
7 However, hostapd sends a broadcast deauth frame on teardown for which tx
8 status is requested. This can lead to the "Have pending ack frames"
9 warning on module reload.
10 Fix this by using ieee80211_free_txskb/ieee80211_purge_tx_queue.
11
12 Signed-off-by: Felix Fietkau <nbd@nbd.name>
13 ---
14
15 --- a/net/mac80211/cfg.c
16 +++ b/net/mac80211/cfg.c
17 @@ -868,7 +868,7 @@ static int ieee80211_stop_ap(struct wiph
18
19 /* free all potentially still buffered bcast frames */
20 local->total_ps_buffered -= skb_queue_len(&sdata->u.ap.ps.bc_buf);
21 - skb_queue_purge(&sdata->u.ap.ps.bc_buf);
22 + ieee80211_purge_tx_queue(&local->hw, &sdata->u.ap.ps.bc_buf);
23
24 mutex_lock(&local->mtx);
25 ieee80211_vif_copy_chanctx_to_vlans(sdata, true);
26 --- a/net/mac80211/tx.c
27 +++ b/net/mac80211/tx.c
28 @@ -368,7 +368,7 @@ static void purge_old_ps_buffers(struct
29 skb = skb_dequeue(&ps->bc_buf);
30 if (skb) {
31 purged++;
32 - dev_kfree_skb(skb);
33 + ieee80211_free_txskb(&local->hw, skb);
34 }
35 total += skb_queue_len(&ps->bc_buf);
36 }
37 @@ -451,7 +451,7 @@ ieee80211_tx_h_multicast_ps_buf(struct i
38 if (skb_queue_len(&ps->bc_buf) >= AP_MAX_BC_BUFFER) {
39 ps_dbg(tx->sdata,
40 "BC TX buffer full - dropping the oldest frame\n");
41 - dev_kfree_skb(skb_dequeue(&ps->bc_buf));
42 + ieee80211_free_txskb(&tx->local->hw, skb_dequeue(&ps->bc_buf));
43 } else
44 tx->local->total_ps_buffered++;
45
46 @@ -4276,7 +4276,7 @@ ieee80211_get_buffered_bc(struct ieee802
47 sdata = IEEE80211_DEV_TO_SUB_IF(skb->dev);
48 if (!ieee80211_tx_prepare(sdata, &tx, NULL, skb))
49 break;
50 - dev_kfree_skb_any(skb);
51 + ieee80211_free_txskb(hw, skb);
52 }
53
54 info = IEEE80211_SKB_CB(skb);