瀏覽代碼

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
wadesong 7 年之前
父節點
當前提交
ae4ffd1f24
共有 2 個文件被更改,包括 29 次插入9 次删除
  1. 24 3
      core/cds/src/cds_api.c
  2. 5 6
      core/hdd/src/wlan_hdd_main.c

+ 24 - 3
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;
 }
 
 /**

+ 5 - 6
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);