forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/net/wireless/marvell/mwifiex/sta_rx.c
....@@ -1,10 +1,10 @@
11 /*
2
- * Marvell Wireless LAN device driver: station RX data handling
2
+ * NXP Wireless LAN device driver: station RX data handling
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.,
....@@ -98,12 +98,23 @@
9898 rx_pkt_len = le16_to_cpu(local_rx_pd->rx_pkt_length);
9999 rx_pkt_hdr = (void *)local_rx_pd + rx_pkt_off;
100100
101
- if ((!memcmp(&rx_pkt_hdr->rfc1042_hdr, bridge_tunnel_header,
102
- sizeof(bridge_tunnel_header))) ||
103
- (!memcmp(&rx_pkt_hdr->rfc1042_hdr, rfc1042_header,
104
- sizeof(rfc1042_header)) &&
105
- ntohs(rx_pkt_hdr->rfc1042_hdr.snap_type) != ETH_P_AARP &&
106
- ntohs(rx_pkt_hdr->rfc1042_hdr.snap_type) != ETH_P_IPX)) {
101
+ if (sizeof(rx_pkt_hdr->eth803_hdr) + sizeof(rfc1042_header) +
102
+ rx_pkt_off > skb->len) {
103
+ mwifiex_dbg(priv->adapter, ERROR,
104
+ "wrong rx packet offset: len=%d, rx_pkt_off=%d\n",
105
+ skb->len, rx_pkt_off);
106
+ priv->stats.rx_dropped++;
107
+ dev_kfree_skb_any(skb);
108
+ return -1;
109
+ }
110
+
111
+ if (sizeof(*rx_pkt_hdr) + rx_pkt_off <= skb->len &&
112
+ ((!memcmp(&rx_pkt_hdr->rfc1042_hdr, bridge_tunnel_header,
113
+ sizeof(bridge_tunnel_header))) ||
114
+ (!memcmp(&rx_pkt_hdr->rfc1042_hdr, rfc1042_header,
115
+ sizeof(rfc1042_header)) &&
116
+ ntohs(rx_pkt_hdr->rfc1042_hdr.snap_type) != ETH_P_AARP &&
117
+ ntohs(rx_pkt_hdr->rfc1042_hdr.snap_type) != ETH_P_IPX))) {
107118 /*
108119 * Replace the 803 header and rfc1042 header (llc/snap) with an
109120 * EthernetII header, keep the src/dst and snap_type
....@@ -152,14 +163,17 @@
152163 mwifiex_process_tdls_action_frame(priv, offset, rx_pkt_len);
153164 }
154165
155
- priv->rxpd_rate = local_rx_pd->rx_rate;
156
-
157
- priv->rxpd_htinfo = local_rx_pd->ht_info;
166
+ /* Only stash RX bitrate for unicast packets. */
167
+ if (likely(!is_multicast_ether_addr(rx_pkt_hdr->eth803_hdr.h_dest))) {
168
+ priv->rxpd_rate = local_rx_pd->rx_rate;
169
+ priv->rxpd_htinfo = local_rx_pd->ht_info;
170
+ }
158171
159172 if (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA ||
160173 GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_UAP) {
161
- adj_rx_rate = mwifiex_adjust_data_rate(priv, priv->rxpd_rate,
162
- priv->rxpd_htinfo);
174
+ adj_rx_rate = mwifiex_adjust_data_rate(priv,
175
+ local_rx_pd->rx_rate,
176
+ local_rx_pd->ht_info);
163177 mwifiex_hist_data_add(priv, adj_rx_rate, local_rx_pd->snr,
164178 local_rx_pd->nf);
165179 }
....@@ -203,7 +217,8 @@
203217
204218 rx_pkt_hdr = (void *)local_rx_pd + rx_pkt_offset;
205219
206
- if ((rx_pkt_offset + rx_pkt_length) > (u16) skb->len) {
220
+ if ((rx_pkt_offset + rx_pkt_length) > skb->len ||
221
+ sizeof(rx_pkt_hdr->eth803_hdr) + rx_pkt_offset > skb->len) {
207222 mwifiex_dbg(adapter, ERROR,
208223 "wrong rx packet: len=%d, rx_pkt_offset=%d, rx_pkt_length=%d\n",
209224 skb->len, rx_pkt_offset, rx_pkt_length);
....@@ -247,7 +262,8 @@
247262 local_rx_pd->nf);
248263 }
249264 } else {
250
- if (rx_pkt_type != PKT_TYPE_BAR)
265
+ if (rx_pkt_type != PKT_TYPE_BAR &&
266
+ local_rx_pd->priority < MAX_NUM_TID)
251267 priv->rx_seq[local_rx_pd->priority] = seq_num;
252268 memcpy(ta, priv->curr_bss_params.bss_descriptor.mac_address,
253269 ETH_ALEN);