wifi: mt76: mt7915: fix possible unaligned access in mt7915_mac_add_twt_setup
authorLorenzo Bianconi <lorenzo@kernel.org>
Mon, 25 Jul 2022 09:50:03 +0000 (11:50 +0200)
committerFelix Fietkau <nbd@nbd.name>
Thu, 15 Sep 2022 10:54:00 +0000 (12:54 +0200)
Fix possible unaligned pointer in mt7915_mac_add_twt_setup routine.

Reported-by: kernel test robot <lkp@intel.com>
Fixes: 3782b69d03e71 ("mt76: mt7915: introduce mt7915_mac_add_twt_setup routine")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7915/mac.c

index 4ddcd3afa428ff6cf9792b3c779cb71c07e75d08..49aa5c056063e3e0d04309fdbc51730824b57c67 100644 (file)
@@ -2071,8 +2071,9 @@ void mt7915_mac_add_twt_setup(struct ieee80211_hw *hw,
        }
 
        flowid = ffs(~msta->twt.flowid_mask) - 1;
-       le16p_replace_bits(&twt_agrt->req_type, flowid,
-                          IEEE80211_TWT_REQTYPE_FLOWID);
+       twt_agrt->req_type &= ~cpu_to_le16(IEEE80211_TWT_REQTYPE_FLOWID);
+       twt_agrt->req_type |= le16_encode_bits(flowid,
+                                              IEEE80211_TWT_REQTYPE_FLOWID);
 
        table_id = ffs(~dev->twt.table_mask) - 1;
        exp = FIELD_GET(IEEE80211_TWT_REQTYPE_WAKE_INT_EXP, req_type);
@@ -2122,8 +2123,9 @@ void mt7915_mac_add_twt_setup(struct ieee80211_hw *hw,
 unlock:
        mutex_unlock(&dev->mt76.mutex);
 out:
-       le16p_replace_bits(&twt_agrt->req_type, setup_cmd,
-                          IEEE80211_TWT_REQTYPE_SETUP_CMD);
+       twt_agrt->req_type &= ~cpu_to_le16(IEEE80211_TWT_REQTYPE_SETUP_CMD);
+       twt_agrt->req_type |=
+               le16_encode_bits(setup_cmd, IEEE80211_TWT_REQTYPE_SETUP_CMD);
        twt->control = (twt->control & IEEE80211_TWT_CONTROL_WAKE_DUR_UNIT) |
                       (twt->control & IEEE80211_TWT_CONTROL_RX_DISABLED);
 }