forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/net/wireless/marvell/mwifiex/uap_txrx.c
....@@ -1,10 +1,10 @@
11 /*
2
- * Marvell Wireless LAN device driver: AP TX and RX data handling
2
+ * NXP Wireless LAN device driver: AP TX and RX data handling
33 *
4
- * Copyright (C) 2012-2014, Marvell International Ltd.
4
+ * Copyright 2011-2020 NXP
55 *
6
- * This software file (the "File") is distributed by Marvell International
7
- * Ltd. under the terms of the GNU General Public License Version 2, June 1991
6
+ * This software file (the "File") is distributed by NXP
7
+ * under the terms of the GNU General Public License Version 2, June 1991
88 * (the "License"). You may use, redistribute and/or modify this File in
99 * accordance with the terms and conditions of the License, a copy of which
1010 * is available by writing to the Free Software Foundation, Inc.,
....@@ -71,11 +71,10 @@
7171 */
7272 static void mwifiex_uap_cleanup_tx_queues(struct mwifiex_private *priv)
7373 {
74
- unsigned long flags;
7574 struct list_head *ra_list;
7675 int i;
7776
78
- spin_lock_irqsave(&priv->wmm.ra_list_spinlock, flags);
77
+ spin_lock_bh(&priv->wmm.ra_list_spinlock);
7978
8079 for (i = 0; i < MAX_NUM_TID; i++, priv->del_list_idx++) {
8180 if (priv->del_list_idx == MAX_NUM_TID)
....@@ -87,7 +86,7 @@
8786 }
8887 }
8988
90
- spin_unlock_irqrestore(&priv->wmm.ra_list_spinlock, flags);
89
+ spin_unlock_bh(&priv->wmm.ra_list_spinlock);
9190 }
9291
9392
....@@ -113,6 +112,16 @@
113112 "Tx: Bridge packet limit reached. Drop packet!\n");
114113 kfree_skb(skb);
115114 mwifiex_uap_cleanup_tx_queues(priv);
115
+ return;
116
+ }
117
+
118
+ if (sizeof(*rx_pkt_hdr) +
119
+ le16_to_cpu(uap_rx_pd->rx_pkt_offset) > skb->len) {
120
+ mwifiex_dbg(adapter, ERROR,
121
+ "wrong rx packet offset: len=%d,rx_pkt_offset=%d\n",
122
+ skb->len, le16_to_cpu(uap_rx_pd->rx_pkt_offset));
123
+ priv->stats.rx_dropped++;
124
+ dev_kfree_skb_any(skb);
116125 return;
117126 }
118127
....@@ -256,7 +265,15 @@
256265
257266 if (is_multicast_ether_addr(ra)) {
258267 skb_uap = skb_copy(skb, GFP_ATOMIC);
259
- mwifiex_uap_queue_bridged_pkt(priv, skb_uap);
268
+ if (likely(skb_uap)) {
269
+ mwifiex_uap_queue_bridged_pkt(priv, skb_uap);
270
+ } else {
271
+ mwifiex_dbg(adapter, ERROR,
272
+ "failed to copy skb for uAP\n");
273
+ priv->stats.rx_dropped++;
274
+ dev_kfree_skb_any(skb);
275
+ return -1;
276
+ }
260277 } else {
261278 if (mwifiex_get_sta_entry(priv, ra)) {
262279 /* Requeue Intra-BSS packet */
....@@ -351,11 +368,7 @@
351368 skb->truesize += (skb->len - MWIFIEX_RX_DATA_BUF_SIZE);
352369
353370 /* Forward multicast/broadcast packet to upper layer*/
354
- if (in_interrupt())
355
- netif_rx(skb);
356
- else
357
- netif_rx_ni(skb);
358
-
371
+ netif_rx_any_context(skb);
359372 return 0;
360373 }
361374
....@@ -378,12 +391,21 @@
378391 struct rx_packet_hdr *rx_pkt_hdr;
379392 u16 rx_pkt_type;
380393 u8 ta[ETH_ALEN], pkt_type;
381
- unsigned long flags;
382394 struct mwifiex_sta_node *node;
383395
384396 uap_rx_pd = (struct uap_rxpd *)(skb->data);
385397 rx_pkt_type = le16_to_cpu(uap_rx_pd->rx_pkt_type);
386398 rx_pkt_hdr = (void *)uap_rx_pd + le16_to_cpu(uap_rx_pd->rx_pkt_offset);
399
+
400
+ if (le16_to_cpu(uap_rx_pd->rx_pkt_offset) +
401
+ sizeof(rx_pkt_hdr->eth803_hdr) > skb->len) {
402
+ mwifiex_dbg(adapter, ERROR,
403
+ "wrong rx packet for struct ethhdr: len=%d, offset=%d\n",
404
+ skb->len, le16_to_cpu(uap_rx_pd->rx_pkt_offset));
405
+ priv->stats.rx_dropped++;
406
+ dev_kfree_skb_any(skb);
407
+ return 0;
408
+ }
387409
388410 ether_addr_copy(ta, rx_pkt_hdr->eth803_hdr.h_source);
389411
....@@ -413,12 +435,12 @@
413435
414436
415437 if (rx_pkt_type != PKT_TYPE_BAR && uap_rx_pd->priority < MAX_NUM_TID) {
416
- spin_lock_irqsave(&priv->sta_list_spinlock, flags);
438
+ spin_lock_bh(&priv->sta_list_spinlock);
417439 node = mwifiex_get_sta_entry(priv, ta);
418440 if (node)
419441 node->rx_seq[uap_rx_pd->priority] =
420442 le16_to_cpu(uap_rx_pd->seq_num);
421
- spin_unlock_irqrestore(&priv->sta_list_spinlock, flags);
443
+ spin_unlock_bh(&priv->sta_list_spinlock);
422444 }
423445
424446 if (!priv->ap_11n_enabled ||