941-mwl8k-Fix-rate_idx-underflow.patch 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. From b897577af85bb5e5638efa780bc3716fae5212d3 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Petr=20=C5=A0tetiar?= <[email protected]>
  3. Date: Mon, 8 Apr 2019 09:45:56 +0200
  4. Subject: [PATCH] mwl8k: Fix rate_idx underflow
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. It was reported on OpenWrt bug tracking system[1], that several users
  9. are affected by the endless reboot of their routers if they configure
  10. 5GHz interface with channel 44 or 48.
  11. The reboot loop is caused by the following excessive number of WARN_ON
  12. messages:
  13. WARNING: CPU: 0 PID: 0 at backports-4.19.23-1/net/mac80211/rx.c:4516
  14. ieee80211_rx_napi+0x1fc/0xa54 [mac80211]
  15. as the messages are being correctly emitted by the following guard:
  16. case RX_ENC_LEGACY:
  17. if (WARN_ON(status->rate_idx >= sband->n_bitrates))
  18. as the rate_idx is in this case erroneously set to 251 (0xfb). This fix
  19. simply converts previously used magic number to proper constant and
  20. guards against substraction which is leading to the currently observed
  21. underflow.
  22. 1. https://bugs.openwrt.org/index.php?do=details&task_id=2218
  23. Fixes: 854783444bab ("mwl8k: properly set receive status rate index on 5 GHz receive")
  24. Cc: <[email protected]>
  25. Tested-by: Eubert Bao <[email protected]>
  26. Reported-by: Eubert Bao <[email protected]>
  27. Signed-off-by: Petr Štetiar <[email protected]>
  28. ---
  29. drivers/net/wireless/marvell/mwl8k.c | 13 +++++++++----
  30. 1 file changed, 9 insertions(+), 4 deletions(-)
  31. diff --git a/drivers/net/wireless/marvell/mwl8k.c b/drivers/net/wireless/marvell/mwl8k.c
  32. index 8e4e9b6..ffc565a 100644
  33. --- a/drivers/net/wireless/marvell/mwl8k.c
  34. +++ b/drivers/net/wireless/marvell/mwl8k.c
  35. @@ -441,6 +441,9 @@ struct mwl8k_sta {
  36. #define MWL8K_CMD_UPDATE_STADB 0x1123
  37. #define MWL8K_CMD_BASTREAM 0x1125
  38. +#define MWL8K_LEGACY_5G_RATE_OFFSET \
  39. + (ARRAY_SIZE(mwl8k_rates_24) - ARRAY_SIZE(mwl8k_rates_50))
  40. +
  41. static const char *mwl8k_cmd_name(__le16 cmd, char *buf, int bufsize)
  42. {
  43. u16 command = le16_to_cpu(cmd);
  44. @@ -1016,8 +1019,9 @@ static void mwl8k_rxd_ap_refill(void *_rxd, dma_addr_t addr, int len)
  45. if (rxd->channel > 14) {
  46. status->band = NL80211_BAND_5GHZ;
  47. - if (!(status->encoding == RX_ENC_HT))
  48. - status->rate_idx -= 5;
  49. + if (!(status->encoding == RX_ENC_HT) &&
  50. + status->rate_idx >= MWL8K_LEGACY_5G_RATE_OFFSET)
  51. + status->rate_idx -= MWL8K_LEGACY_5G_RATE_OFFSET;
  52. } else {
  53. status->band = NL80211_BAND_2GHZ;
  54. }
  55. @@ -1124,8 +1128,9 @@ static void mwl8k_rxd_sta_refill(void *_rxd, dma_addr_t addr, int len)
  56. if (rxd->channel > 14) {
  57. status->band = NL80211_BAND_5GHZ;
  58. - if (!(status->encoding == RX_ENC_HT))
  59. - status->rate_idx -= 5;
  60. + if (!(status->encoding == RX_ENC_HT) &&
  61. + status->rate_idx >= MWL8K_LEGACY_5G_RATE_OFFSET)
  62. + status->rate_idx -= MWL8K_LEGACY_5G_RATE_OFFSET;
  63. } else {
  64. status->band = NL80211_BAND_2GHZ;
  65. }
  66. --
  67. 1.9.1