600f7c37df709a8cac3479cae00901ce42dd2bdd
[openwrt/staging/pepe2k.git] /
1 From 513c559ca9f05394da79fbf20a8f89eec5f53dce Mon Sep 17 00:00:00 2001
2 From: Ping-Ke Shih <pkshih@realtek.com>
3 Date: Fri, 16 Feb 2024 11:39:23 +0800
4 Subject: [PATCH] wifi: rtl8xxxu: check vif before using in rtl8xxxu_tx()
5
6 The 'vif' is from tx_info of SKB, and other codes check 'vif' before using,
7 which raises smatch warnings:
8
9 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c:5656 rtl8xxxu_tx()
10 warn: variable dereferenced before check 'vif' (see line 5553)
11
12 Compile tested only.
13
14 Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
15 Signed-off-by: Kalle Valo <kvalo@kernel.org>
16 Link: https://msgid.link/20240216033923.34683-1-pkshih@realtek.com
17 ---
18 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 4 ++--
19 1 file changed, 2 insertions(+), 2 deletions(-)
20
21 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
22 +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
23 @@ -5550,7 +5550,7 @@ static void rtl8xxxu_tx(struct ieee80211
24 struct rtl8xxxu_tx_urb *tx_urb;
25 struct ieee80211_sta *sta = NULL;
26 struct ieee80211_vif *vif = tx_info->control.vif;
27 - struct rtl8xxxu_vif *rtlvif = (struct rtl8xxxu_vif *)vif->drv_priv;
28 + struct rtl8xxxu_vif *rtlvif = vif ? (struct rtl8xxxu_vif *)vif->drv_priv : NULL;
29 struct device *dev = &priv->udev->dev;
30 u32 queue, rts_rate;
31 u16 pktlen = skb->len;
32 @@ -5621,7 +5621,7 @@ static void rtl8xxxu_tx(struct ieee80211
33 default:
34 break;
35 }
36 - if (bmc && rtlvif->hw_key_idx != 0xff) {
37 + if (bmc && rtlvif && rtlvif->hw_key_idx != 0xff) {
38 tx_desc->txdw1 |= cpu_to_le32(TXDESC_EN_DESC_ID);
39 macid = rtlvif->hw_key_idx;
40 }