From 5e7ad9b03f1cffd35763f510ed001a70f2e26e34 Mon Sep 17 00:00:00 2001 From: Arif Hussain Date: Wed, 20 Dec 2017 16:29:10 -0800 Subject: [PATCH] qcacmn: Add null pointer validation and fix initialization in dfs Add validation check for memory allocation and initialize variable before using. Change-Id: If5215f4f034ea57884b252f8467c4e2ca227c952 CRs-Fixed: 2160749 --- umac/dfs/core/src/misc/dfs.c | 6 ++---- umac/dfs/core/src/misc/dfs_zero_cac.c | 5 +++++ umac/dfs/dispatcher/src/wlan_dfs_init_deinit_api.c | 6 +++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/umac/dfs/core/src/misc/dfs.c b/umac/dfs/core/src/misc/dfs.c index a38501ca1066..3c6df56993ca 100644 --- a/umac/dfs/core/src/misc/dfs.c +++ b/umac/dfs/core/src/misc/dfs.c @@ -293,10 +293,8 @@ bad1: qdf_mem_free(dfs->pulses); dfs->pulses = NULL; } - if (dfs->events) { - qdf_mem_free(dfs->events); - dfs->events = NULL; - } + qdf_mem_free(dfs->events); + dfs->events = NULL; return 1; } diff --git a/umac/dfs/core/src/misc/dfs_zero_cac.c b/umac/dfs/core/src/misc/dfs_zero_cac.c index 0505633d646f..5685481801ee 100644 --- a/umac/dfs/core/src/misc/dfs_zero_cac.c +++ b/umac/dfs/core/src/misc/dfs_zero_cac.c @@ -534,6 +534,11 @@ void dfs_init_precac_list(struct wlan_dfs *dfs) precac_entry = qdf_mem_malloc( sizeof(*precac_entry)); + if (!precac_entry) { + dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS, + "entry alloc fail for : %d", i); + continue; + } precac_entry->vht80_freq = ichan->dfs_ch_vhtop_ch_freq_seg1; precac_entry->dfs = dfs; diff --git a/umac/dfs/dispatcher/src/wlan_dfs_init_deinit_api.c b/umac/dfs/dispatcher/src/wlan_dfs_init_deinit_api.c index 5b5344200a66..8496499cb597 100644 --- a/umac/dfs/dispatcher/src/wlan_dfs_init_deinit_api.c +++ b/umac/dfs/dispatcher/src/wlan_dfs_init_deinit_api.c @@ -209,7 +209,7 @@ QDF_STATUS wlan_dfs_pdev_obj_create_notification(struct wlan_objmgr_pdev *pdev, QDF_STATUS wlan_dfs_pdev_obj_destroy_notification(struct wlan_objmgr_pdev *pdev, void *arg) { - struct wlan_dfs *dfs; + struct wlan_dfs *dfs = NULL; if (!pdev) { dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS, "PDEV is NULL"); @@ -219,7 +219,7 @@ QDF_STATUS wlan_dfs_pdev_obj_destroy_notification(struct wlan_objmgr_pdev *pdev, dfs = wlan_pdev_get_dfs_obj(pdev); /* DFS is NULL during unload. should we call this function before */ - if (dfs != NULL) { + if (dfs) { global_dfs_to_mlme.pdev_component_obj_detach(pdev, WLAN_UMAC_COMP_DFS, (void *)dfs); @@ -237,7 +237,7 @@ static void dfs_scan_serialization_comp_info_cb( struct wlan_objmgr_vdev *vdev, union wlan_serialization_rules_info *comp_info) { - struct wlan_dfs *dfs; + struct wlan_dfs *dfs = NULL; struct wlan_objmgr_pdev *pdev; if (!comp_info) {