From 4620e06006579cbbc2023b92a3a6c2bc95529b93 Mon Sep 17 00:00:00 2001 From: Chaithanya Garrepalli Date: Wed, 1 Nov 2023 22:48:37 +0530 Subject: [PATCH] qcacmn: Handle race between WDS add vs peer delete In case where WDS ast entry is added and next hop peer is deleted even before PEER map for ast entry is received free the AST entry Change-Id: Id65a5649665588e98f85fd0f363bc7d114c56828 CRs-Fixed: 3650748 --- dp/wifi3.0/dp_peer.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/dp/wifi3.0/dp_peer.c b/dp/wifi3.0/dp_peer.c index 60c1d4b340..a54ae0ad98 100644 --- a/dp/wifi3.0/dp_peer.c +++ b/dp/wifi3.0/dp_peer.c @@ -1534,10 +1534,6 @@ static inline QDF_STATUS dp_peer_map_ast(struct dp_soc *soc, if (soc->ast_offload_support && !wlan_cfg_get_dp_soc_dpdk_cfg(soc->ctrl_psoc)) return QDF_STATUS_SUCCESS; - if (!peer) { - return QDF_STATUS_E_INVAL; - } - dp_peer_err("%pK: peer %pK ID %d vid %d mac " QDF_MAC_ADDR_FMT, soc, peer, hw_peer_id, vdev_id, QDF_MAC_ADDR_REF(mac_addr)); @@ -1547,6 +1543,21 @@ static inline QDF_STATUS dp_peer_map_ast(struct dp_soc *soc, ast_entry = dp_peer_ast_hash_find_by_vdevid(soc, mac_addr, vdev_id); if (is_wds) { + /* + * While processing peer map of AST entry if the next hop peer is + * deleted free the AST entry as it is not attached to peer yet + */ + if (!peer) { + if (ast_entry) + dp_peer_free_ast_entry(soc, ast_entry); + + qdf_spin_unlock_bh(&soc->ast_lock); + + dp_peer_alert("Peer is NULL for WDS entry mac " + QDF_MAC_ADDR_FMT " ", + QDF_MAC_ADDR_REF(mac_addr)); + return QDF_STATUS_E_INVAL; + } /* * In certain cases like Auth attack on a repeater * can result in the number of ast_entries falling @@ -1597,6 +1608,13 @@ static inline QDF_STATUS dp_peer_map_ast(struct dp_soc *soc, } } + if (!peer) { + qdf_spin_unlock_bh(&soc->ast_lock); + dp_peer_alert("Peer is NULL for mac " QDF_MAC_ADDR_FMT " ", + QDF_MAC_ADDR_REF(mac_addr)); + return QDF_STATUS_E_INVAL; + } + if (ast_entry) { ast_entry->ast_idx = hw_peer_id; soc->ast_table[hw_peer_id] = ast_entry;