Skip to contentSkip to conversation

wifi: rtl8xxxu: check vif before using in rtl8xxxu_tx()

PATCH In review Ping-Ke Shih 2 participants 2 messages Feb 16, 2024 – Feb 21, 2024 RTL8XXXU wireless driver (rtl8xxxu)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 wifi: rtl8xxxu: check vif before using in rtl8xxxu_tx()

The 'vif' is from tx_info of SKB, and other codes check 'vif' before using, which raises smatch warnings:

drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c:5656 rtl8xxxu_tx()
warn: variable dereferenced before check 'vif' (see line 5553)

Compile tested only.

---
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +2 -2
index 66bf92c164c3..40edf55d8e4a 100644
@@ -5550,7 +5550,7 @@ static void rtl8xxxu_tx(struct ieee80211_hw *hw,
 	struct rtl8xxxu_tx_urb *tx_urb;
 	struct ieee80211_sta *sta = NULL;
 	struct ieee80211_vif *vif = tx_info->control.vif;
-	struct rtl8xxxu_vif *rtlvif = (struct rtl8xxxu_vif *)vif->drv_priv;
+	struct rtl8xxxu_vif *rtlvif = vif ? (struct rtl8xxxu_vif *)vif->drv_priv : NULL;
 	struct device *dev = &priv->udev->dev;
 	u32 queue, rts_rate;
 	u16 pktlen = skb->len;
@@ -5621,7 +5621,7 @@ static void rtl8xxxu_tx(struct ieee80211_hw *hw,
 		default:
 			break;
 		}
-		if (bmc && rtlvif->hw_key_idx != 0xff) {
+		if (bmc && rtlvif && rtlvif->hw_key_idx != 0xff) {
 			tx_desc->txdw1 |= cpu_to_le32(TXDESC_EN_DESC_ID);
 			macid = rtlvif->hw_key_idx;
 		}
Signature · 1 line
2.25.1
#1 lore raw
Quoted 9 lines · Ping-Ke Shih

The 'vif' is from tx_info of SKB, and other codes check 'vif' before using, which raises smatch warnings:

drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c:5656 rtl8xxxu_tx()
warn: variable dereferenced before check 'vif' (see line 5553)

Compile tested only.

Patch applied to wireless-next.git, thanks.

513c559ca9f0 wifi: rtl8xxxu: check vif before using in rtl8xxxu_tx()

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches