Skip to content

Commit 371a75d

Browse files
Sriram Rgregkh
Sriram R
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 [Freescale#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] Signed-off-by: Sasha Levin <[email protected]>
1 parent dbba817 commit 371a75d

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

+20-15
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>
@@ -4136,23 +4137,32 @@ static int __ath11k_set_antenna(struct ath11k *ar, u32 tx_ant, u32 rx_ant)
41364137
return 0;
41374138
}
41384139

4139-
int ath11k_mac_tx_mgmt_pending_free(int buf_id, void *skb, void *ctx)
4140+
static void ath11k_mac_tx_mgmt_free(struct ath11k *ar, int buf_id)
41404141
{
4141-
struct sk_buff *msdu = skb;
4142+
struct sk_buff *msdu;
41424143
struct ieee80211_tx_info *info;
4143-
struct ath11k *ar = ctx;
4144-
struct ath11k_base *ab = ar->ab;
41454144

41464145
spin_lock_bh(&ar->txmgmt_idr_lock);
4147-
idr_remove(&ar->txmgmt_idr, buf_id);
4146+
msdu = idr_remove(&ar->txmgmt_idr, buf_id);
41484147
spin_unlock_bh(&ar->txmgmt_idr_lock);
4149-
dma_unmap_single(ab->dev, ATH11K_SKB_CB(msdu)->paddr, msdu->len,
4148+
4149+
if (!msdu)
4150+
return;
4151+
4152+
dma_unmap_single(ar->ab->dev, ATH11K_SKB_CB(msdu)->paddr, msdu->len,
41504153
DMA_TO_DEVICE);
41514154

41524155
info = IEEE80211_SKB_CB(msdu);
41534156
memset(&info->status, 0, sizeof(info->status));
41544157

41554158
ieee80211_free_txskb(ar->hw, msdu);
4159+
}
4160+
4161+
int ath11k_mac_tx_mgmt_pending_free(int buf_id, void *skb, void *ctx)
4162+
{
4163+
struct ath11k *ar = ctx;
4164+
4165+
ath11k_mac_tx_mgmt_free(ar, buf_id);
41564166

41574167
return 0;
41584168
}
@@ -4161,17 +4171,10 @@ static int ath11k_mac_vif_txmgmt_idr_remove(int buf_id, void *skb, void *ctx)
41614171
{
41624172
struct ieee80211_vif *vif = ctx;
41634173
struct ath11k_skb_cb *skb_cb = ATH11K_SKB_CB((struct sk_buff *)skb);
4164-
struct sk_buff *msdu = skb;
41654174
struct ath11k *ar = skb_cb->ar;
4166-
struct ath11k_base *ab = ar->ab;
41674175

4168-
if (skb_cb->vif == vif) {
4169-
spin_lock_bh(&ar->txmgmt_idr_lock);
4170-
idr_remove(&ar->txmgmt_idr, buf_id);
4171-
spin_unlock_bh(&ar->txmgmt_idr_lock);
4172-
dma_unmap_single(ab->dev, skb_cb->paddr, msdu->len,
4173-
DMA_TO_DEVICE);
4174-
}
4176+
if (skb_cb->vif == vif)
4177+
ath11k_mac_tx_mgmt_free(ar, buf_id);
41754178

41764179
return 0;
41774180
}
@@ -4186,6 +4189,8 @@ static int ath11k_mac_mgmt_tx_wmi(struct ath11k *ar, struct ath11k_vif *arvif,
41864189
int buf_id;
41874190
int ret;
41884191

4192+
ATH11K_SKB_CB(skb)->ar = ar;
4193+
41894194
spin_lock_bh(&ar->txmgmt_idr_lock);
41904195
buf_id = idr_alloc(&ar->txmgmt_idr, skb, 0,
41914196
ATH11K_TX_MGMT_NUM_PENDING_MAX, GFP_ATOMIC);

0 commit comments

Comments
 (0)