qcacld-3.0: Free the adapter runtime PM lock in error cases

Currently runtime PM lock for adapter is not freed in error cases
of hdd_open_adapter() which will result memory leak. Free it correctly
in the function for failure cases.

Change-Id: Ie325de8b2789c461d139dbea9001cbb0504bc024
CRs-fixed: 2142668
diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c
index 56fe662..94f4b69 100644
--- a/core/hdd/src/wlan_hdd_main.c
+++ b/core/hdd/src/wlan_hdd_main.c
@@ -972,7 +972,7 @@
 	qdf_runtime_lock_init(&ctx->connect);
 }
 
-static void hdd_adapter_runtime_suspend_denit(struct hdd_adapter *adapter)
+static void hdd_adapter_runtime_suspend_deinit(struct hdd_adapter *adapter)
 {
 	struct hdd_connect_pm_context *ctx = &adapter->connect_rpm_ctx;
 
@@ -982,7 +982,7 @@
 static void hdd_runtime_suspend_context_init(struct hdd_context *hdd_ctx) {}
 static void hdd_runtime_suspend_context_deinit(struct hdd_context *hdd_ctx) {}
 static void hdd_adapter_runtime_suspend_init(struct hdd_adapter *adapter) {}
-static void hdd_adapter_runtime_suspend_denit(struct hdd_adapter *adapter) {}
+static void hdd_adapter_runtime_suspend_deinit(struct hdd_adapter *adapter) {}
 #endif /* FEATURE_RUNTIME_PM */
 
 #define INTF_MACADDR_MASK       0x7
@@ -3630,7 +3630,7 @@
 		adapter->scan_info.default_scan_ies = NULL;
 	}
 
-	hdd_adapter_runtime_suspend_denit(adapter);
+	hdd_adapter_runtime_suspend_deinit(adapter);
 
 	/*
 	 * The adapter is marked as closed. When hdd_wlan_exit() call returns,
@@ -4015,7 +4015,7 @@
 		status = hdd_register_interface(adapter, rtnl_held);
 		if (QDF_STATUS_SUCCESS != status) {
 			hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held);
-			goto err_free_netdev;
+			goto err_deinit_adapter_runtime_pm;
 		}
 
 		/* Stop the Interface TX queue. */
@@ -4028,7 +4028,7 @@
 		if (QDF_NDI_MODE == session_type) {
 			status = hdd_init_nan_data_mode(adapter);
 			if (QDF_STATUS_SUCCESS != status)
-				goto err_free_netdev;
+				goto err_deinit_adapter_runtime_pm;
 		}
 
 		break;
@@ -4089,7 +4089,7 @@
 		status = hdd_register_interface(adapter, rtnl_held);
 		if (QDF_STATUS_SUCCESS != status) {
 			hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held);
-			goto err_free_netdev;
+			goto err_deinit_adapter_runtime_pm;
 		}
 		/* Stop the Interface TX queue. */
 		hdd_debug("Disabling queues");
@@ -4150,6 +4150,12 @@
 
 	return adapter;
 
+err_deinit_adapter_runtime_pm:
+	/*
+	 * For certain error cases that hdd_alloc_station_adapter()
+	 * is used to allocate the adapter.
+	 */
+	hdd_adapter_runtime_suspend_deinit(adapter);
 err_free_netdev:
 	wlan_hdd_release_intf_addr(hdd_ctx, adapter->mac_addr.bytes);
 	free_netdev(adapter->dev);