009-v6.9-wifi-rtl8xxxu-check-vif-before-using-in-rtl8xxxu_tx.patch 1.6 KB

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