Skip to content

Commit fb3c19b

Browse files
yogeshpowarlinvjw
authored andcommitted
mwifiex: adding check for enough space before padding
All MSDUs, except the last one in an AMSDU, should end up at 4 bytes boundary. There is need to check if enough skb_tailroom space exists before padding the skb. Also re-arranging code for better readablity. Signed-off-by: Yogesh Ashok Powar <[email protected]> Signed-off-by: John W. Linville <[email protected]>
1 parent a8fe329 commit fb3c19b

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

drivers/net/wireless/mwifiex/11n_aggr.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -185,16 +185,15 @@ mwifiex_11n_aggregate_pkt(struct mwifiex_private *priv,
185185
tx_info_aggr->bss_index = tx_info_src->bss_index;
186186
skb_aggr->priority = skb_src->priority;
187187

188-
while (skb_src && ((skb_headroom(skb_aggr) + skb_src->len
189-
+ LLC_SNAP_LEN)
190-
<= adapter->tx_buf_size)) {
188+
do {
189+
/* Check if AMSDU can accommodate this MSDU */
190+
if (skb_tailroom(skb_aggr) < (skb_src->len + LLC_SNAP_LEN))
191+
break;
191192

192193
skb_src = skb_dequeue(&pra_list->skb_head);
193194

194-
if (skb_src) {
195-
pra_list->total_pkts_size -= skb_src->len;
196-
pra_list->total_pkts--;
197-
}
195+
pra_list->total_pkts_size -= skb_src->len;
196+
pra_list->total_pkts--;
198197

199198
atomic_dec(&priv->wmm.tx_pkts_queued);
200199

@@ -212,8 +211,15 @@ mwifiex_11n_aggregate_pkt(struct mwifiex_private *priv,
212211
return -1;
213212
}
214213

214+
if (skb_tailroom(skb_aggr) < pad) {
215+
pad = 0;
216+
break;
217+
}
218+
skb_put(skb_aggr, pad);
219+
215220
skb_src = skb_peek(&pra_list->skb_head);
216-
}
221+
222+
} while (skb_src);
217223

218224
spin_unlock_irqrestore(&priv->wmm.ra_list_spinlock, ra_list_flags);
219225

0 commit comments

Comments
 (0)