Message ID | 20240826014942.87783-2-quic_bqiang@quicinc.com |
---|---|
State | New |
Headers | show |
Series | wifi: ath11k: fix memory leak in reset scenario | expand |
On 8/25/2024 6:49 PM, Baochen Qiang wrote: > Currently ath11k_dp_peer_cleanup() acquires ab->base_lock inside itself. This is > working because it is only called in below context where that lock is not held: > > ath11k_mac_op_sta_state() --> ath11k_mac_station_remove() > > In a upcoming patch that fixes memory leak in reset scenario, we need to do the > same job as ath11k_dp_peer_cleanup(). However ab->base_lock is already held there > so we can not directly call it. > > So the decision is to move lock/unlock outside of ath11k_dp_peer_cleanup() such > that we won't get deadlock in a context where the lock is already held. In order > to make sure it is called with lock held, add LOCKDEP assertion there. > > Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3.6510.30 > > Signed-off-by: Baochen Qiang <quic_bqiang@quicinc.com> Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com>
diff --git a/drivers/net/wireless/ath/ath11k/dp.c b/drivers/net/wireless/ath/ath11k/dp.c index fbf666d0ecf1..58f57dd8858f 100644 --- a/drivers/net/wireless/ath/ath11k/dp.c +++ b/drivers/net/wireless/ath/ath11k/dp.c @@ -26,19 +26,18 @@ void ath11k_dp_peer_cleanup(struct ath11k *ar, int vdev_id, const u8 *addr) /* TODO: Any other peer specific DP cleanup */ - spin_lock_bh(&ab->base_lock); + lockdep_assert_held(&ab->base_lock); + peer = ath11k_peer_find(ab, vdev_id, addr); if (!peer) { ath11k_warn(ab, "failed to lookup peer %pM on vdev %d\n", addr, vdev_id); - spin_unlock_bh(&ab->base_lock); return; } ath11k_peer_rx_tid_cleanup(ar, peer); peer->dp_setup_done = false; crypto_free_shash(peer->tfm_mmic); - spin_unlock_bh(&ab->base_lock); } int ath11k_dp_peer_setup(struct ath11k *ar, int vdev_id, const u8 *addr) diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c index f8068d2e848c..f1dff26bc237 100644 --- a/drivers/net/wireless/ath/ath11k/mac.c +++ b/drivers/net/wireless/ath/ath11k/mac.c @@ -9531,7 +9531,9 @@ static int ath11k_mac_station_remove(struct ath11k *ar, } } + spin_lock_bh(&ab->base_lock); ath11k_dp_peer_cleanup(ar, arvif->vdev_id, sta->addr); + spin_unlock_bh(&ab->base_lock); ret = ath11k_peer_delete(ar, arvif->vdev_id, sta->addr); if (ret)
Currently ath11k_dp_peer_cleanup() acquires ab->base_lock inside itself. This is working because it is only called in below context where that lock is not held: ath11k_mac_op_sta_state() --> ath11k_mac_station_remove() In a upcoming patch that fixes memory leak in reset scenario, we need to do the same job as ath11k_dp_peer_cleanup(). However ab->base_lock is already held there so we can not directly call it. So the decision is to move lock/unlock outside of ath11k_dp_peer_cleanup() such that we won't get deadlock in a context where the lock is already held. In order to make sure it is called with lock held, add LOCKDEP assertion there. Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3.6510.30 Signed-off-by: Baochen Qiang <quic_bqiang@quicinc.com> --- drivers/net/wireless/ath/ath11k/dp.c | 5 ++--- drivers/net/wireless/ath/ath11k/mac.c | 2 ++ 2 files changed, 4 insertions(+), 3 deletions(-)