From 4c3fbb400e28d1bbb0b67f9b1fa6e483d24b891a Mon Sep 17 00:00:00 2001 From: Amar Singhal Date: Tue, 2 Jan 2018 13:20:28 -0800 Subject: [PATCH] qcacld-3.0: Fix NULL pointer and uninitialization issues Fix NULL pointer and uninitialization issues. Change-Id: I757b3b408f9ddc8716366a757ea2bf2bb7126a38 CRs-Fixed: 2162258 --- core/wma/src/wma_dev_if.c | 7 ++++--- core/wma/src/wma_features.c | 8 +++++++- core/wma/src/wma_main.c | 16 ++++++++++++++-- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/core/wma/src/wma_dev_if.c b/core/wma/src/wma_dev_if.c index 1c2229d6aa72..cdd1826187c4 100644 --- a/core/wma/src/wma_dev_if.c +++ b/core/wma/src/wma_dev_if.c @@ -3733,7 +3733,7 @@ static void wma_add_bss_sta_mode(tp_wma_handle wma, tpAddBssParams add_bss) struct wma_vdev_start_req req; struct wma_target_req *msg; uint8_t vdev_id = 0, peer_id; - void *peer; + void *peer = NULL; QDF_STATUS status; struct wma_txrx_node *iface; int pps_val = 0; @@ -4007,8 +4007,9 @@ send_final_rsp: return; peer_cleanup: - wma_remove_peer(wma, add_bss->bssId, vdev_id, peer, - roam_synch_in_progress); + if (peer) + wma_remove_peer(wma, add_bss->bssId, vdev_id, peer, + roam_synch_in_progress); send_fail_resp: add_bss->status = QDF_STATUS_E_FAILURE; if (!wma_is_roam_synch_in_progress(wma, vdev_id)) diff --git a/core/wma/src/wma_features.c b/core/wma/src/wma_features.c index 214e7db94745..d8086c828b57 100644 --- a/core/wma/src/wma_features.c +++ b/core/wma/src/wma_features.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. * @@ -1228,6 +1228,12 @@ void wma_check_and_set_wake_timer(uint32_t time) struct wma_txrx_node *iface; t_wma_handle *wma = cds_get_context(QDF_MODULE_ID_WMA); + if (!wma) { + WMA_LOGE("%s: WMA is closed", + __func__); + return; + } + if (!WMI_SERVICE_EXT_IS_ENABLED(wma->wmi_service_bitmap, wma->wmi_service_ext_bitmap, WMI_SERVICE_WOW_WAKEUP_BY_TIMER_PATTERN)) { diff --git a/core/wma/src/wma_main.c b/core/wma/src/wma_main.c index d7a9c4347e2b..44af8ea4388c 100644 --- a/core/wma/src/wma_main.c +++ b/core/wma/src/wma_main.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. * @@ -5517,6 +5517,11 @@ bool wma_is_rx_ldpc_supported_for_channel(uint32_t channel) enum cds_band_type band; bool status; + if (!wma_handle) { + WMA_LOGE("Invalid wma handle"); + return false; + } + if (!WLAN_REG_IS_24GHZ_CH(channel)) band = CDS_BAND_5GHZ; else @@ -5882,7 +5887,14 @@ static void wma_init_wifi_pos_dma_rings(t_wma_handle *wma_handle, uint8_t num_mac, void *buf) { struct hif_softc *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); - void *hal_soc = hif_get_hal_handle(hif_ctx); + void *hal_soc; + + if (!hif_ctx) { + WMA_LOGE("invalid hif context"); + return; + } + + hal_soc = hif_get_hal_handle(hif_ctx); wifi_pos_init_cir_cfr_rings(wma_handle->psoc, hal_soc, num_mac, buf); }