From 01a45f7d335755cdc5be205db14d954e18487c18 Mon Sep 17 00:00:00 2001 From: Yun Park Date: Thu, 4 Jan 2018 15:30:59 -0800 Subject: [PATCH] qcacld-3.0: Fix static analysis issues in wma Resolve static analysis issues - NULL pointer dereference and array boundary checking. Change-Id: Ia509cdb9b61d4f7b86175e3b3ec6d4691fc1f7a2 CRs-Fixed: 2162260 --- core/wma/src/wma_mgmt.c | 9 +++------ core/wma/src/wma_scan_roam.c | 5 +++++ core/wma/src/wma_utils.c | 7 ++++++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/core/wma/src/wma_mgmt.c b/core/wma/src/wma_mgmt.c index 7d0ca346a9d0..7889df76c936 100644 --- a/core/wma/src/wma_mgmt.c +++ b/core/wma/src/wma_mgmt.c @@ -3499,8 +3499,7 @@ static bool wma_is_pkt_drop_candidate(tp_wma_handle wma_handle, should_drop = true; } } - *cdp_peer_last_assoc_received(soc, peer) = - qdf_get_system_timestamp(); + *ptr = qdf_get_system_timestamp(); break; case IEEE80211_FC0_SUBTYPE_DISASSOC: ptr = cdp_peer_last_disassoc_received(soc, peer); @@ -3515,8 +3514,7 @@ static bool wma_is_pkt_drop_candidate(tp_wma_handle wma_handle, should_drop = true; } } - *cdp_peer_last_disassoc_received(soc, peer) = - qdf_get_system_timestamp(); + *ptr = qdf_get_system_timestamp(); break; case IEEE80211_FC0_SUBTYPE_DEAUTH: ptr = cdp_peer_last_deauth_received(soc, peer); @@ -3531,8 +3529,7 @@ static bool wma_is_pkt_drop_candidate(tp_wma_handle wma_handle, should_drop = true; } } - *cdp_peer_last_deauth_received(soc, peer) = - qdf_get_system_timestamp(); + *ptr = qdf_get_system_timestamp(); break; default: break; diff --git a/core/wma/src/wma_scan_roam.c b/core/wma/src/wma_scan_roam.c index b7e60d231892..707bb73f643b 100644 --- a/core/wma/src/wma_scan_roam.c +++ b/core/wma/src/wma_scan_roam.c @@ -6112,6 +6112,11 @@ QDF_STATUS wma_get_scan_id(uint32_t *scan_id) return QDF_STATUS_E_FAULT; } + if (!wma) { + WMA_LOGE("%s: wma handle is NULL", __func__); + return QDF_STATUS_E_INVAL; + } + #ifdef NAPIER_SCAN *scan_id = ucfg_scan_get_scan_id(wma->psoc); #else diff --git a/core/wma/src/wma_utils.c b/core/wma/src/wma_utils.c index 24b0d9b24dab..ba401951ae0a 100644 --- a/core/wma/src/wma_utils.c +++ b/core/wma/src/wma_utils.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2017 The Linux Foundation. All rights reserved. + * Copyright (c) 2013-2018 The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * @@ -4666,6 +4666,11 @@ bool wma_is_service_enabled(WMI_SERVICE service_type) return false; } + if (service_type >= WMI_MAX_SERVICE) { + WMA_LOGE("%s: Invalid service type %d", __func__, service_type); + return false; + } + return WMI_SERVICE_IS_ENABLED(wma->wmi_service_bitmap, service_type); }