From ae4ffd1f24d8c92e3b8659ce25eb7cf673cd5759 Mon Sep 17 00:00:00 2001 From: wadesong Date: Tue, 24 Oct 2017 16:45:54 +0800 Subject: [PATCH] qcacld-3.0: Populate proper return value on failure 1) Function return value is not checked after cds recovery work init, which may result in improper status to be returned. Return an error status code if cds recovery work init job is not successful so caller can know something abnormal happened, such as memory allocation failure. 2) Return value should be checked immediately after invoking cds_init to make sure no improper init happens. Change-Id: Ic01436f075f9e1b0a96d3daa6902b598f5f6657e CRs-Fixed: 2133200 --- core/cds/src/cds_api.c | 27 ++++++++++++++++++++++++--- core/hdd/src/wlan_hdd_main.c | 11 +++++------ 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/core/cds/src/cds_api.c b/core/cds/src/cds_api.c index 3f17581aab6c..c62eff2e0c67 100644 --- a/core/cds/src/cds_api.c +++ b/core/cds/src/cds_api.c @@ -160,7 +160,14 @@ uint8_t cds_get_datapath_handles(void **soc, struct cdp_pdev **pdev, QDF_STATUS cds_init(void) { - qdf_debugfs_init(); + QDF_STATUS ret; + + ret = qdf_debugfs_init(); + if (ret != QDF_STATUS_SUCCESS) { + cds_err("Failed to init debugfs"); + goto err_ret; + } + qdf_lock_stats_init(); qdf_mem_init(); qdf_mc_timer_manager_init(); @@ -181,9 +188,23 @@ QDF_STATUS cds_init(void) cds_ssr_protect_init(); - cds_recovery_work_init(); + ret = cds_recovery_work_init(); + if (ret != QDF_STATUS_SUCCESS) { + cds_err("Failed to init recovery work"); + goto deinit; + } - return gp_cds_context ? QDF_STATUS_SUCCESS : QDF_STATUS_E_FAILURE; + return QDF_STATUS_SUCCESS; +deinit: + qdf_mc_timer_manager_exit(); + qdf_mem_exit(); + qdf_lock_stats_deinit(); + qdf_debugfs_exit(); + gp_cds_context->qdf_ctx = NULL; + gp_cds_context = NULL; + qdf_mem_zero(&g_cds_context, sizeof(g_cds_context)); +err_ret: + return ret; } /** diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c index 21e97836507a..6f120a2c425f 100644 --- a/core/hdd/src/wlan_hdd_main.c +++ b/core/hdd/src/wlan_hdd_main.c @@ -11031,6 +11031,11 @@ int hdd_init(void) int ret = 0; status = cds_init(); + if (QDF_IS_STATUS_ERROR(status)) { + hdd_err("Failed to allocate CDS context"); + ret = -ENOMEM; + goto err_out; + } wlan_init_bug_report_lock(); @@ -11038,12 +11043,6 @@ int hdd_init(void) wlan_logging_sock_init_svc(); #endif - if (QDF_IS_STATUS_ERROR(status)) { - hdd_err("Failed to allocate CDS context"); - ret = -ENOMEM; - goto err_out; - } - qdf_timer_init(NULL, &hdd_drv_ops_inactivity_timer, (void *)hdd_drv_ops_inactivity_handler, NULL, QDF_TIMER_TYPE_SW);