mwifiex: add a bounds check in mwifiex_process_sta_rx_packet()
authorDan Carpenter <dan.carpenter@oracle.com>
Tue, 2 Apr 2019 07:03:38 +0000 (10:03 +0300)
committerKalle Valo <kvalo@codeaurora.org>
Thu, 4 Apr 2019 10:20:47 +0000 (13:20 +0300)
Smatch complains that "local_rx_pd->priority" can't be trusted because
it comes from skb->data and it can go up to 255 instead of being capped
in the 0-7 range.  A few lines earlier, on the other side of the if
statement, we cap priority so it seems harmless to add a bounds check
here as well.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/marvell/mwifiex/sta_rx.c

index fb28a5c7f4416bc84ed0b6a279c39af1db72d4f8..52a2ce2e78b081625caf933323e008b2bfe6dbc8 100644 (file)
@@ -250,7 +250,8 @@ int mwifiex_process_sta_rx_packet(struct mwifiex_private *priv,
                                                             local_rx_pd->nf);
                }
        } else {
-               if (rx_pkt_type != PKT_TYPE_BAR)
+               if (rx_pkt_type != PKT_TYPE_BAR &&
+                   local_rx_pd->priority < MAX_NUM_TID)
                        priv->rx_seq[local_rx_pd->priority] = seq_num;
                memcpy(ta, priv->curr_bss_params.bss_descriptor.mac_address,
                       ETH_ALEN);