rtw89: Fix variable dereferenced before check 'sta'
Ping-Ke Shih
maintainerPATCH 1/1 rtw89: Fix variable dereferenced before check 'sta'
The pointer rtwsta is dereferencing pointer sta before sta is being null checked. Fix this by assigning sta->drv_priv to rtwsta only if sta is not NULL, otherwise just NULL.
Fixes e3ec7017f6a2 ("rtw89: add Realtek 802.11ax driver")
Reported-by Colin Ian King <[email protected]>
Signed-off-by Ping-Ke Shih <[email protected]>
--- drivers/net/wireless/realtek/rtw89/core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/wireless/realtek/rtw89/core.c +3 -3
@@ -1412,7 +1412,7 @@ static void rtw89_core_ba_work(struct work_struct *work)list_for_each_entry_safe (rtwtxq, tmp, &rtwdev->ba_list, list) {struct ieee80211_txq *txq =rtw89_txq_to_txq (rtwtxq);struct ieee80211_sta *sta = txq->sta; -struct rtw89_sta *rtwsta = (struct rtw89_sta *)sta->drv_priv; +struct rtw89_sta *rtwsta = sta ? (struct rtw89_sta *)sta->drv_priv :NULL ;u8 tid = txq->tid;if (!sta) {
@@ -1462,7 +1462,7 @@ static void rtw89_core_txq_check_agg(struct rtw89_dev *rtwdev,struct ieee80211_hw *hw = rtwdev->hw;struct ieee80211_txq *txq =rtw89_txq_to_txq (rtwtxq);struct ieee80211_sta *sta = txq->sta; -struct rtw89_sta *rtwsta = (struct rtw89_sta *)sta->drv_priv; +struct rtw89_sta *rtwsta = sta ? (struct rtw89_sta *)sta->drv_priv :NULL ;if (unlikely (skb_get_queue_mapping (skb) ==IEEE80211_AC_VO ))return ;
@@ -1534,7 +1534,7 @@ static bool rtw89_core_txq_agg_wait(struct rtw89_dev *rtwdev, {struct rtw89_txq *rtwtxq = (struct rtw89_txq *)txq->drv_priv;struct ieee80211_sta *sta = txq->sta; -struct rtw89_sta *rtwsta = (struct rtw89_sta *)sta->drv_priv; +struct rtw89_sta *rtwsta = sta ? (struct rtw89_sta *)sta->drv_priv :NULL ;if (!sta || rtwsta->max_agg_wait <=0 )return false;
Signature · 1 line
2.25.1
Quoted 7 lines · Ping-Ke Shih
The pointer rtwsta is dereferencing pointer sta before sta is being null checked. Fix this by assigning
sta->drv_privto rtwsta only if sta is not NULL, otherwise just NULL.Fixes e3ec7017f6a2 ("rtw89: add Realtek 802.11ax driver")Reported-by Colin Ian King <[email protected]>Signed-off-by Ping-Ke Shih <[email protected]>
Patch applied to wireless-drivers-next.git, thanks.
5d44f0672319 rtw89: Fix variable dereferenced before check 'sta'
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches