hc
2024-05-10 37f49e37ab4cb5d0bc4c60eb5c6d4dd57db767bb
kernel/drivers/net/wireless/marvell/mwifiex/util.c
....@@ -1,10 +1,10 @@
11 /*
2
- * Marvell Wireless LAN device driver: utility functions
2
+ * NXP Wireless LAN device driver: utility functions
33 *
4
- * Copyright (C) 2011-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.,
....@@ -405,11 +405,15 @@
405405 }
406406
407407 rx_pd = (struct rxpd *)skb->data;
408
+ pkt_len = le16_to_cpu(rx_pd->rx_pkt_length);
409
+ if (pkt_len < sizeof(struct ieee80211_hdr) + sizeof(pkt_len)) {
410
+ mwifiex_dbg(priv->adapter, ERROR, "invalid rx_pkt_length");
411
+ return -1;
412
+ }
408413
409414 skb_pull(skb, le16_to_cpu(rx_pd->rx_pkt_offset));
410415 skb_pull(skb, sizeof(pkt_len));
411
-
412
- pkt_len = le16_to_cpu(rx_pd->rx_pkt_length);
416
+ pkt_len -= sizeof(pkt_len);
413417
414418 ieee_hdr = (void *)skb->data;
415419 if (ieee80211_is_mgmt(ieee_hdr->frame_control)) {
....@@ -422,7 +426,7 @@
422426 skb->data + sizeof(struct ieee80211_hdr),
423427 pkt_len - sizeof(struct ieee80211_hdr));
424428
425
- pkt_len -= ETH_ALEN + sizeof(pkt_len);
429
+ pkt_len -= ETH_ALEN;
426430 rx_pd->rx_pkt_length = cpu_to_le16(pkt_len);
427431
428432 cfg80211_rx_mgmt(&priv->wdev, priv->roc_cfg.chan.center_freq,
....@@ -488,11 +492,7 @@
488492 (skb->truesize > MWIFIEX_RX_DATA_BUF_SIZE))
489493 skb->truesize += (skb->len - MWIFIEX_RX_DATA_BUF_SIZE);
490494
491
- if (in_interrupt())
492
- netif_rx(skb);
493
- else
494
- netif_rx_ni(skb);
495
-
495
+ netif_rx_any_context(skb);
496496 return 0;
497497 }
498498
....@@ -607,12 +607,11 @@
607607 mwifiex_add_sta_entry(struct mwifiex_private *priv, const u8 *mac)
608608 {
609609 struct mwifiex_sta_node *node;
610
- unsigned long flags;
611610
612611 if (!mac)
613612 return NULL;
614613
615
- spin_lock_irqsave(&priv->sta_list_spinlock, flags);
614
+ spin_lock_bh(&priv->sta_list_spinlock);
616615 node = mwifiex_get_sta_entry(priv, mac);
617616 if (node)
618617 goto done;
....@@ -625,7 +624,7 @@
625624 list_add_tail(&node->list, &priv->sta_list);
626625
627626 done:
628
- spin_unlock_irqrestore(&priv->sta_list_spinlock, flags);
627
+ spin_unlock_bh(&priv->sta_list_spinlock);
629628 return node;
630629 }
631630
....@@ -662,9 +661,8 @@
662661 void mwifiex_del_sta_entry(struct mwifiex_private *priv, const u8 *mac)
663662 {
664663 struct mwifiex_sta_node *node;
665
- unsigned long flags;
666664
667
- spin_lock_irqsave(&priv->sta_list_spinlock, flags);
665
+ spin_lock_bh(&priv->sta_list_spinlock);
668666
669667 node = mwifiex_get_sta_entry(priv, mac);
670668 if (node) {
....@@ -672,7 +670,7 @@
672670 kfree(node);
673671 }
674672
675
- spin_unlock_irqrestore(&priv->sta_list_spinlock, flags);
673
+ spin_unlock_bh(&priv->sta_list_spinlock);
676674 return;
677675 }
678676
....@@ -680,9 +678,8 @@
680678 void mwifiex_del_all_sta_list(struct mwifiex_private *priv)
681679 {
682680 struct mwifiex_sta_node *node, *tmp;
683
- unsigned long flags;
684681
685
- spin_lock_irqsave(&priv->sta_list_spinlock, flags);
682
+ spin_lock_bh(&priv->sta_list_spinlock);
686683
687684 list_for_each_entry_safe(node, tmp, &priv->sta_list, list) {
688685 list_del(&node->list);
....@@ -690,7 +687,7 @@
690687 }
691688
692689 INIT_LIST_HEAD(&priv->sta_list);
693
- spin_unlock_irqrestore(&priv->sta_list_spinlock, flags);
690
+ spin_unlock_bh(&priv->sta_list_spinlock);
694691 return;
695692 }
696693