Skip to content

Commit adbe148

Browse files
Sriram Rgregkh
authored andcommitted
ath11k: Avoid NULL ptr access during mgmt tx cleanup
[ Upstream commit a93789a ] Currently 'ar' reference is not added in skb_cb during WMI mgmt tx. Though this is generally not used during tx completion callbacks, on interface removal the remaining idr cleanup callback uses the ar ptr from skb_cb from mgmt txmgmt_idr. Hence fill them during tx call for proper usage. Also free the skb which is missing currently in these callbacks. Crash_info: [19282.489476] Unable to handle kernel NULL pointer dereference at virtual address 00000000 [19282.489515] pgd = 91eb8000 [19282.496702] [00000000] *pgd=00000000 [19282.502524] Internal error: Oops: 5 [raspberrypi#1] PREEMPT SMP ARM [19282.783728] PC is at ath11k_mac_vif_txmgmt_idr_remove+0x28/0xd8 [ath11k] [19282.789170] LR is at idr_for_each+0xa0/0xc8 Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.5.0.1-00729-QCAHKSWPL_SILICONZ-3 v2 Signed-off-by: Sriram R <quic_srirrama@quicinc.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/1637832614-13831-1-git-send-email-quic_srirrama@quicinc.com Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent ab523ea commit adbe148

1 file changed

Lines changed: 20 additions & 15 deletions

File tree

  • drivers/net/wireless/ath/ath11k

‎drivers/net/wireless/ath/ath11k/mac.c‎

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// SPDX-License-Identifier: BSD-3-Clause-Clear
22
/*
33
* Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
4+
* Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved.
45
*/
56

67
#include <net/mac80211.h>
@@ -3883,23 +3884,32 @@ static int __ath11k_set_antenna(struct ath11k *ar, u32 tx_ant, u32 rx_ant)
38833884
return 0;
38843885
}
38853886

3886-
int ath11k_mac_tx_mgmt_pending_free(int buf_id, void *skb, void *ctx)
3887+
static void ath11k_mac_tx_mgmt_free(struct ath11k *ar, int buf_id)
38873888
{
3888-
struct sk_buff *msdu = skb;
3889+
struct sk_buff *msdu;
38893890
struct ieee80211_tx_info *info;
3890-
struct ath11k *ar = ctx;
3891-
struct ath11k_base *ab = ar->ab;
38923891

38933892
spin_lock_bh(&ar->txmgmt_idr_lock);
3894-
idr_remove(&ar->txmgmt_idr, buf_id);
3893+
msdu = idr_remove(&ar->txmgmt_idr, buf_id);
38953894
spin_unlock_bh(&ar->txmgmt_idr_lock);
3896-
dma_unmap_single(ab->dev, ATH11K_SKB_CB(msdu)->paddr, msdu->len,
3895+
3896+
if (!msdu)
3897+
return;
3898+
3899+
dma_unmap_single(ar->ab->dev, ATH11K_SKB_CB(msdu)->paddr, msdu->len,
38973900
DMA_TO_DEVICE);
38983901

38993902
info = IEEE80211_SKB_CB(msdu);
39003903
memset(&info->status, 0, sizeof(info->status));
39013904

39023905
ieee80211_free_txskb(ar->hw, msdu);
3906+
}
3907+
3908+
int ath11k_mac_tx_mgmt_pending_free(int buf_id, void *skb, void *ctx)
3909+
{
3910+
struct ath11k *ar = ctx;
3911+
3912+
ath11k_mac_tx_mgmt_free(ar, buf_id);
39033913

39043914
return 0;
39053915
}
@@ -3908,17 +3918,10 @@ static int ath11k_mac_vif_txmgmt_idr_remove(int buf_id, void *skb, void *ctx)
39083918
{
39093919
struct ieee80211_vif *vif = ctx;
39103920
struct ath11k_skb_cb *skb_cb = ATH11K_SKB_CB((struct sk_buff *)skb);
3911-
struct sk_buff *msdu = skb;
39123921
struct ath11k *ar = skb_cb->ar;
3913-
struct ath11k_base *ab = ar->ab;
39143922

3915-
if (skb_cb->vif == vif) {
3916-
spin_lock_bh(&ar->txmgmt_idr_lock);
3917-
idr_remove(&ar->txmgmt_idr, buf_id);
3918-
spin_unlock_bh(&ar->txmgmt_idr_lock);
3919-
dma_unmap_single(ab->dev, skb_cb->paddr, msdu->len,
3920-
DMA_TO_DEVICE);
3921-
}
3923+
if (skb_cb->vif == vif)
3924+
ath11k_mac_tx_mgmt_free(ar, buf_id);
39223925

39233926
return 0;
39243927
}
@@ -3933,6 +3936,8 @@ static int ath11k_mac_mgmt_tx_wmi(struct ath11k *ar, struct ath11k_vif *arvif,
39333936
int buf_id;
39343937
int ret;
39353938

3939+
ATH11K_SKB_CB(skb)->ar = ar;
3940+
39363941
spin_lock_bh(&ar->txmgmt_idr_lock);
39373942
buf_id = idr_alloc(&ar->txmgmt_idr, skb, 0,
39383943
ATH11K_TX_MGMT_NUM_PENDING_MAX, GFP_ATOMIC);

0 commit comments

Comments
 (0)