From 3ce25ed456324123d8efcfc74baaa5d0e12e04a1 Mon Sep 17 00:00:00 2001 From: Krishna Kumaar Natarajan Date: Tue, 24 Jan 2017 18:28:11 -0800 Subject: [PATCH] qcacld-3.0: Fix cdp API null check in wma_is_pkt_drop_candidate() Fix cdp API null check in wma_is_pkt_drop_candidate. Add check if _last_received is greater than 0 before checking for DOS attack. Change-Id: Ic817e9a3d59100be5cb97f833985b7633391e1ca CRs-Fixed: 1115648 --- core/wma/src/wma_mgmt.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/core/wma/src/wma_mgmt.c b/core/wma/src/wma_mgmt.c index 0193a693da..896d70e475 100644 --- a/core/wma/src/wma_mgmt.c +++ b/core/wma/src/wma_mgmt.c @@ -3114,9 +3114,8 @@ static bool wma_is_pkt_drop_candidate(tp_wma_handle wma_handle, WMA_LOGE(FL("cdp_peer_last_assoc_received Failed")); should_drop = true; goto end; - } else { - if ((qdf_get_system_timestamp() - - *cdp_peer_last_assoc_received(soc, peer)) < + } else if (*ptr > 0) { + if ((qdf_get_system_timestamp() - *ptr) < WMA_MGMT_FRAME_DETECT_DOS_TIMER) { WMA_LOGI(FL("Dropping Assoc Req received")); should_drop = true; @@ -3126,9 +3125,13 @@ static bool wma_is_pkt_drop_candidate(tp_wma_handle wma_handle, qdf_get_system_timestamp(); break; case SIR_MAC_MGMT_DISASSOC: - if (*cdp_peer_last_disassoc_received(soc, peer)) { - if ((qdf_get_system_timestamp() - - *cdp_peer_last_disassoc_received(soc, peer)) < + ptr = cdp_peer_last_disassoc_received(soc, peer); + if (ptr == NULL) { + WMA_LOGE(FL("cdp_peer_last_disassoc_received Failed")); + should_drop = true; + goto end; + } else if (*ptr > 0) { + if ((qdf_get_system_timestamp() - *ptr) < WMA_MGMT_FRAME_DETECT_DOS_TIMER) { WMA_LOGI(FL("Dropping DisAssoc received")); should_drop = true; @@ -3138,9 +3141,13 @@ static bool wma_is_pkt_drop_candidate(tp_wma_handle wma_handle, qdf_get_system_timestamp(); break; case SIR_MAC_MGMT_DEAUTH: - if (*cdp_peer_last_deauth_received(soc, peer)) { - if ((qdf_get_system_timestamp() - - *cdp_peer_last_deauth_received(soc, peer)) < + ptr = cdp_peer_last_deauth_received(soc, peer); + if (ptr == NULL) { + WMA_LOGE(FL("cdp_peer_last_deauth_received Failed")); + should_drop = true; + goto end; + } else if (*ptr > 0) { + if ((qdf_get_system_timestamp() - *ptr) < WMA_MGMT_FRAME_DETECT_DOS_TIMER) { WMA_LOGI(FL("Dropping Deauth received")); should_drop = true;