Skip to content

Commit a93789a

Browse files
Sriram RKalle Valo
Sriram R
authored and
Kalle Valo
committed
ath11k: Avoid NULL ptr access during mgmt tx cleanup
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 [#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 <[email protected]> Signed-off-by: Kalle Valo <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 23cddeb commit a93789a

File tree

1 file changed

+20
-15
lines changed
  • drivers/net/wireless/ath/ath11k

1 file changed

+20
-15
lines changed

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>
@@ -5224,23 +5225,32 @@ static int __ath11k_set_antenna(struct ath11k *ar, u32 tx_ant, u32 rx_ant)
52245225
return 0;
52255226
}
52265227

5227-
int ath11k_mac_tx_mgmt_pending_free(int buf_id, void *skb, void *ctx)
5228+
static void ath11k_mac_tx_mgmt_free(struct ath11k *ar, int buf_id)
52285229
{
5229-
struct sk_buff *msdu = skb;
5230+
struct sk_buff *msdu;
52305231
struct ieee80211_tx_info *info;
5231-
struct ath11k *ar = ctx;
5232-
struct ath11k_base *ab = ar->ab;
52335232

52345233
spin_lock_bh(&ar->txmgmt_idr_lock);
5235-
idr_remove(&ar->txmgmt_idr, buf_id);
5234+
msdu = idr_remove(&ar->txmgmt_idr, buf_id);
52365235
spin_unlock_bh(&ar->txmgmt_idr_lock);
5237-
dma_unmap_single(ab->dev, ATH11K_SKB_CB(msdu)->paddr, msdu->len,
5236+
5237+
if (!msdu)
5238+
return;
5239+
5240+
dma_unmap_single(ar->ab->dev, ATH11K_SKB_CB(msdu)->paddr, msdu->len,
52385241
DMA_TO_DEVICE);
52395242

52405243
info = IEEE80211_SKB_CB(msdu);
52415244
memset(&info->status, 0, sizeof(info->status));
52425245

52435246
ieee80211_free_txskb(ar->hw, msdu);
5247+
}
5248+
5249+
int ath11k_mac_tx_mgmt_pending_free(int buf_id, void *skb, void *ctx)
5250+
{
5251+
struct ath11k *ar = ctx;
5252+
5253+
ath11k_mac_tx_mgmt_free(ar, buf_id);
52445254

52455255
return 0;
52465256
}
@@ -5249,17 +5259,10 @@ static int ath11k_mac_vif_txmgmt_idr_remove(int buf_id, void *skb, void *ctx)
52495259
{
52505260
struct ieee80211_vif *vif = ctx;
52515261
struct ath11k_skb_cb *skb_cb = ATH11K_SKB_CB((struct sk_buff *)skb);
5252-
struct sk_buff *msdu = skb;
52535262
struct ath11k *ar = skb_cb->ar;
5254-
struct ath11k_base *ab = ar->ab;
52555263

5256-
if (skb_cb->vif == vif) {
5257-
spin_lock_bh(&ar->txmgmt_idr_lock);
5258-
idr_remove(&ar->txmgmt_idr, buf_id);
5259-
spin_unlock_bh(&ar->txmgmt_idr_lock);
5260-
dma_unmap_single(ab->dev, skb_cb->paddr, msdu->len,
5261-
DMA_TO_DEVICE);
5262-
}
5264+
if (skb_cb->vif == vif)
5265+
ath11k_mac_tx_mgmt_free(ar, buf_id);
52635266

52645267
return 0;
52655268
}
@@ -5274,6 +5277,8 @@ static int ath11k_mac_mgmt_tx_wmi(struct ath11k *ar, struct ath11k_vif *arvif,
52745277
int buf_id;
52755278
int ret;
52765279

5280+
ATH11K_SKB_CB(skb)->ar = ar;
5281+
52775282
spin_lock_bh(&ar->txmgmt_idr_lock);
52785283
buf_id = idr_alloc(&ar->txmgmt_idr, skb, 0,
52795284
ATH11K_TX_MGMT_NUM_PENDING_MAX, GFP_ATOMIC);

0 commit comments

Comments
 (0)