Browse Source

qcacld-3.0: Use get/put to refer vdev [4/4]

Any direct reference to adapter->vdev outside the initial
assignment should use get/put to properly refer the vdev.
        core/hdd/src/wlan_hdd_nan_datapath.c
        core/hdd/src/wlan_hdd_p2p.c
        core/hdd/src/wlan_hdd_softap_tx_rx.c

Change-Id: I2e98ca517c63ad0a03d3539fc9f97f8e466ba2ab
CRs-Fixed: 2714025
Paul Zhang 4 năm trước cách đây
mục cha
commit
a426dc45c3

+ 63 - 14
core/hdd/src/wlan_hdd_nan_datapath.c

@@ -347,7 +347,16 @@ void hdd_ndp_event_handler(struct hdd_adapter *adapter,
 			   eCsrRoamResult roam_result)
 {
 	bool success;
-	struct wlan_objmgr_psoc *psoc = wlan_vdev_get_psoc(adapter->vdev);
+	struct wlan_objmgr_psoc *psoc;
+	struct wlan_objmgr_vdev *vdev;
+
+	vdev = hdd_objmgr_get_vdev(adapter);
+	if (!vdev) {
+		hdd_err("vdev is NULL");
+		return;
+	}
+	psoc = wlan_vdev_get_psoc(vdev);
+	hdd_objmgr_put_vdev(vdev);
 
 	if (roam_status == eCSR_ROAM_NDP_STATUS_UPDATE) {
 		switch (roam_result) {
@@ -437,7 +446,18 @@ int wlan_hdd_cfg80211_process_ndp_cmd(struct wiphy *wiphy,
 
 static int update_ndi_state(struct hdd_adapter *adapter, uint32_t state)
 {
-	return os_if_nan_set_ndi_state(adapter->vdev, state);
+	struct wlan_objmgr_vdev *vdev;
+	QDF_STATUS status;
+
+	vdev = hdd_objmgr_get_vdev(adapter);
+	if (!vdev) {
+		hdd_err("vdev is NULL");
+		return QDF_STATUS_E_NULL_VALUE;
+	}
+	status = os_if_nan_set_ndi_state(vdev, state);
+
+	hdd_objmgr_put_vdev(vdev);
+	return status;
 }
 
 /**
@@ -581,6 +601,7 @@ int hdd_ndi_start(char *iface_name, uint16_t transaction_id)
 	uint8_t op_channel;
 	struct hdd_adapter *adapter;
 	struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
+	struct wlan_objmgr_vdev *vdev;
 
 	hdd_enter();
 	if (!hdd_ctx) {
@@ -602,15 +623,19 @@ int hdd_ndi_start(char *iface_name, uint16_t transaction_id)
 		goto err_handler;
 	}
 
+	vdev = hdd_objmgr_get_vdev(adapter);
+	if (!vdev) {
+		hdd_err("vdev is NULL");
+		ret = -EINVAL;
+		goto err_handler;
+	}
 	/*
 	 * Create transaction id is required to be saved since the firmware
 	 * does not honor the transaction id for create request
 	 */
-	ucfg_nan_set_ndp_create_transaction_id(adapter->vdev,
-					       transaction_id);
-	ucfg_nan_set_ndi_state(adapter->vdev,
-			       NAN_DATA_NDI_CREATING_STATE);
-
+	ucfg_nan_set_ndp_create_transaction_id(vdev, transaction_id);
+	ucfg_nan_set_ndi_state(vdev, NAN_DATA_NDI_CREATING_STATE);
+	hdd_objmgr_put_vdev(vdev);
 	/*
 	 * The NAN data interface has been created at this point.
 	 * Unlike traditional device modes, where the higher application
@@ -650,6 +675,7 @@ int hdd_ndi_delete(uint8_t vdev_id, char *iface_name, uint16_t transaction_id)
 	struct hdd_adapter *adapter;
 	struct hdd_station_ctx *sta_ctx;
 	struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
+	struct wlan_objmgr_vdev *vdev;
 
 	if (!hdd_ctx) {
 		hdd_err("hdd_ctx is null");
@@ -669,10 +695,15 @@ int hdd_ndi_delete(uint8_t vdev_id, char *iface_name, uint16_t transaction_id)
 		return -EINVAL;
 	}
 
-	os_if_nan_set_ndp_delete_transaction_id(adapter->vdev,
-						transaction_id);
-	os_if_nan_set_ndi_state(adapter->vdev, NAN_DATA_NDI_DELETING_STATE);
+	vdev = hdd_objmgr_get_vdev(adapter);
+	if (!vdev) {
+		hdd_err("vdev is NULL");
+		return -EINVAL;
+	}
 
+	os_if_nan_set_ndp_delete_transaction_id(vdev, transaction_id);
+	os_if_nan_set_ndi_state(vdev, NAN_DATA_NDI_DELETING_STATE);
+	hdd_objmgr_put_vdev(vdev);
 	/* Delete the interface */
 	ret = __wlan_hdd_del_virtual_intf(hdd_ctx->wiphy, &adapter->wdev);
 	if (ret)
@@ -694,6 +725,7 @@ void hdd_ndi_drv_ndi_create_rsp_handler(uint8_t vdev_id,
 	uint16_t ndp_inactivity_timeout = 0;
 	uint16_t ndp_keep_alive_period;
 	struct qdf_mac_addr bc_mac_addr = QDF_MAC_ADDR_BCAST_INIT;
+	struct wlan_objmgr_vdev *vdev;
 
 	hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
 	if (!hdd_ctx) {
@@ -719,9 +751,17 @@ void hdd_ndi_drv_ndi_create_rsp_handler(uint8_t vdev_id,
 
 	if (ndi_rsp->status == QDF_STATUS_SUCCESS) {
 		hdd_alert("NDI interface successfully created");
-		os_if_nan_set_ndp_create_transaction_id(adapter->vdev, 0);
-		os_if_nan_set_ndi_state(adapter->vdev,
-					NAN_DATA_NDI_CREATED_STATE);
+		vdev = hdd_objmgr_get_vdev(adapter);
+		if (!vdev) {
+			qdf_mem_free(roam_info);
+			hdd_err("vdev is NULL");
+			return;
+		}
+
+		os_if_nan_set_ndp_create_transaction_id(vdev, 0);
+		os_if_nan_set_ndi_state(vdev, NAN_DATA_NDI_CREATED_STATE);
+		hdd_objmgr_put_vdev(vdev);
+
 		wlan_hdd_netif_queue_control(adapter,
 					WLAN_START_ALL_NETIF_QUEUE_N_CARRIER,
 					WLAN_CONTROL_PATH);
@@ -816,7 +856,16 @@ void hdd_ndi_drv_ndi_delete_rsp_handler(uint8_t vdev_id)
 
 void hdd_ndp_session_end_handler(struct hdd_adapter *adapter)
 {
-	os_if_nan_ndi_session_end(adapter->vdev);
+	struct wlan_objmgr_vdev *vdev;
+
+	vdev = hdd_objmgr_get_vdev(adapter);
+	if (!vdev) {
+		hdd_err("vdev is NULL");
+		return;
+	}
+
+	os_if_nan_ndi_session_end(vdev);
+	hdd_objmgr_put_vdev(vdev);
 }
 
 /**

+ 81 - 15
core/hdd/src/wlan_hdd_p2p.c

@@ -52,6 +52,7 @@
 #include "wlan_policy_mgr_ucfg.h"
 #include "nan_ucfg_api.h"
 #include "wlan_pkt_capture_ucfg_api.h"
+#include "wlan_hdd_object_manager.h"
 
 /* Ms to Time Unit Micro Sec */
 #define MS_TO_TU_MUS(x)   ((x) * 1024)
@@ -85,12 +86,20 @@ const char *tdls_action_frame_type[] = { "TDLS Setup Request",
 
 void wlan_hdd_cancel_existing_remain_on_channel(struct hdd_adapter *adapter)
 {
+	struct wlan_objmgr_vdev *vdev;
+
 	if (!adapter) {
 		hdd_err("null adapter");
 		return;
 	}
 
-	ucfg_p2p_cleanup_roc_by_vdev(adapter->vdev);
+	vdev = hdd_objmgr_get_vdev(adapter);
+	if (!vdev) {
+		hdd_err("vdev is NULL");
+		return;
+	}
+	ucfg_p2p_cleanup_roc_by_vdev(vdev);
+	hdd_objmgr_put_vdev(vdev);
 }
 
 int wlan_hdd_check_remain_on_channel(struct hdd_adapter *adapter)
@@ -104,22 +113,39 @@ int wlan_hdd_check_remain_on_channel(struct hdd_adapter *adapter)
 /* Clean up RoC context at hdd_stop_adapter*/
 void wlan_hdd_cleanup_remain_on_channel_ctx(struct hdd_adapter *adapter)
 {
+	struct wlan_objmgr_vdev *vdev;
+
 	if (!adapter) {
 		hdd_err("null adapter");
 		return;
 	}
 
-	ucfg_p2p_cleanup_roc_by_vdev(adapter->vdev);
+	vdev = hdd_objmgr_get_vdev(adapter);
+	if (!vdev) {
+		hdd_err("vdev is NULL");
+		return;
+	}
+
+	ucfg_p2p_cleanup_roc_by_vdev(vdev);
+	hdd_objmgr_put_vdev(vdev);
 }
 
 void wlan_hdd_cleanup_actionframe(struct hdd_adapter *adapter)
 {
+	struct wlan_objmgr_vdev *vdev;
+
 	if (!adapter) {
 		hdd_err("null adapter");
 		return;
 	}
 
-	ucfg_p2p_cleanup_tx_by_vdev(adapter->vdev);
+	vdev = hdd_objmgr_get_vdev(adapter);
+	if (!vdev) {
+		hdd_err("vdev is NULL");
+		return;
+	}
+	ucfg_p2p_cleanup_tx_by_vdev(vdev);
+	hdd_objmgr_put_vdev(vdev);
 }
 
 static int __wlan_hdd_cfg80211_remain_on_channel(struct wiphy *wiphy,
@@ -131,6 +157,7 @@ static int __wlan_hdd_cfg80211_remain_on_channel(struct wiphy *wiphy,
 	struct net_device *dev = wdev->netdev;
 	struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
 	struct hdd_context *hdd_ctx;
+	struct wlan_objmgr_vdev *vdev;
 	QDF_STATUS status;
 	int ret;
 
@@ -149,10 +176,17 @@ static int __wlan_hdd_cfg80211_remain_on_channel(struct wiphy *wiphy,
 	if (wlan_hdd_validate_vdev_id(adapter->vdev_id))
 		return -EINVAL;
 
+	vdev = hdd_objmgr_get_vdev(adapter);
+	if (!vdev) {
+		hdd_err("vdev is NULL");
+		return -EINVAL;
+	}
+
 	/* Disable NAN Discovery if enabled */
 	ucfg_nan_disable_concurrency(hdd_ctx->psoc);
 
-	status = wlan_cfg80211_roc(adapter->vdev, chan, duration, cookie);
+	status = wlan_cfg80211_roc(vdev, chan, duration, cookie);
+	hdd_objmgr_put_vdev(vdev);
 	hdd_debug("remain on channel request, status:%d, cookie:0x%llx",
 		  status, *cookie);
 
@@ -187,6 +221,7 @@ __wlan_hdd_cfg80211_cancel_remain_on_channel(struct wiphy *wiphy,
 	QDF_STATUS status;
 	struct net_device *dev = wdev->netdev;
 	struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
+	struct wlan_objmgr_vdev *vdev;
 
 	hdd_enter();
 
@@ -198,7 +233,15 @@ __wlan_hdd_cfg80211_cancel_remain_on_channel(struct wiphy *wiphy,
 	if (wlan_hdd_validate_vdev_id(adapter->vdev_id))
 		return -EINVAL;
 
-	status = wlan_cfg80211_cancel_roc(adapter->vdev, cookie);
+	vdev = hdd_objmgr_get_vdev(adapter);
+	if (!vdev) {
+		hdd_err("vdev is NULL");
+		return -EINVAL;
+	}
+
+	status = wlan_cfg80211_cancel_roc(vdev, cookie);
+	hdd_objmgr_put_vdev(vdev);
+
 	hdd_debug("cancel remain on channel, status:%d", status);
 
 	return 0;
@@ -262,6 +305,7 @@ static int __wlan_hdd_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
 	struct net_device *dev = wdev->netdev;
 	struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
 	struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
+	struct wlan_objmgr_vdev *vdev;
 	uint8_t type;
 	uint8_t sub_type;
 	QDF_STATUS qdf_status;
@@ -296,8 +340,7 @@ static int __wlan_hdd_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
 	    (type == SIR_MAC_MGMT_FRAME &&
 	    sub_type == SIR_MAC_MGMT_AUTH)) {
 		qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_SME,
-			   TRACE_CODE_HDD_SEND_MGMT_TX,
-			   wlan_vdev_get_id(adapter->vdev), 0);
+			   TRACE_CODE_HDD_SEND_MGMT_TX, adapter->vdev_id, 0);
 
 		qdf_status = sme_send_mgmt_tx(hdd_ctx->mac_handle,
 					      adapter->vdev_id, buf, len);
@@ -316,12 +359,19 @@ static int __wlan_hdd_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
 
 	wlan_hdd_validate_and_override_offchan(adapter, chan, &offchan);
 
+	vdev = hdd_objmgr_get_vdev(adapter);
+	if (!vdev) {
+		hdd_err("vdev is NULL");
+		return -EINVAL;
+	}
+
 	qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_OS_IF,
 		   TRACE_CODE_HDD_SEND_MGMT_TX,
-		   wlan_vdev_get_id(adapter->vdev), 0);
+		   wlan_vdev_get_id(vdev), 0);
 
-	status = wlan_cfg80211_mgmt_tx(adapter->vdev, chan, offchan, wait, buf,
+	status = wlan_cfg80211_mgmt_tx(vdev, chan, offchan, wait, buf,
 				       len, no_cck, dont_wait_for_ack, cookie);
+	hdd_objmgr_put_vdev(vdev);
 	hdd_debug("mgmt tx, status:%d, cookie:0x%llx", status, *cookie);
 
 	return 0;
@@ -368,6 +418,7 @@ static int __wlan_hdd_cfg80211_mgmt_tx_cancel_wait(struct wiphy *wiphy,
 	QDF_STATUS status;
 	struct net_device *dev = wdev->netdev;
 	struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
+	struct wlan_objmgr_vdev *vdev;
 
 	hdd_enter();
 
@@ -379,7 +430,15 @@ static int __wlan_hdd_cfg80211_mgmt_tx_cancel_wait(struct wiphy *wiphy,
 	if (wlan_hdd_validate_vdev_id(adapter->vdev_id))
 		return -EINVAL;
 
-	status = wlan_cfg80211_mgmt_tx_cancel(adapter->vdev, cookie);
+	vdev = hdd_objmgr_get_vdev(adapter);
+	if (!vdev) {
+		hdd_err("vdev is NULL");
+		return -EINVAL;
+	}
+
+	status = wlan_cfg80211_mgmt_tx_cancel(vdev, cookie);
+	hdd_objmgr_put_vdev(vdev);
+
 	hdd_debug("cancel mgmt tx, status:%d", status);
 
 	return 0;
@@ -635,6 +694,7 @@ struct wireless_dev *__wlan_hdd_add_virtual_intf(struct wiphy *wiphy,
 	bool p2p_dev_addr_admin = false;
 	enum QDF_OPMODE mode;
 	QDF_STATUS status;
+	struct wlan_objmgr_vdev *vdev;
 	int ret;
 
 	hdd_enter();
@@ -677,11 +737,17 @@ struct wireless_dev *__wlan_hdd_add_virtual_intf(struct wiphy *wiphy,
 
 	adapter = hdd_get_adapter(hdd_ctx, QDF_STA_MODE);
 	if (adapter && !wlan_hdd_validate_vdev_id(adapter->vdev_id)) {
-		if (ucfg_scan_get_vdev_status(adapter->vdev) !=
-				SCAN_NOT_IN_PROGRESS) {
-			wlan_abort_scan(hdd_ctx->pdev, INVAL_PDEV_ID,
-					adapter->vdev_id, INVALID_SCAN_ID,
-					false);
+		vdev = hdd_objmgr_get_vdev(adapter);
+		if (vdev) {
+			if (ucfg_scan_get_vdev_status(vdev) !=
+							SCAN_NOT_IN_PROGRESS) {
+				wlan_abort_scan(hdd_ctx->pdev, INVAL_PDEV_ID,
+						adapter->vdev_id,
+						INVALID_SCAN_ID, false);
+			}
+			hdd_objmgr_put_vdev(vdev);
+		} else {
+			hdd_err("vdev is NULL");
 		}
 	}
 

+ 8 - 1
core/hdd/src/wlan_hdd_softap_tx_rx.c

@@ -1330,6 +1330,7 @@ QDF_STATUS hdd_softap_change_sta_state(struct hdd_adapter *adapter,
 	QDF_STATUS qdf_status;
 	struct hdd_station_info *sta_info;
 	struct qdf_mac_addr mac_addr;
+	struct wlan_objmgr_vdev *vdev;
 
 	hdd_enter_dev(adapter->dev);
 
@@ -1354,7 +1355,13 @@ QDF_STATUS hdd_softap_change_sta_state(struct hdd_adapter *adapter,
 
 	if (QDF_STATUS_SUCCESS == qdf_status) {
 		sta_info->peer_state = OL_TXRX_PEER_STATE_AUTH;
-		p2p_peer_authorized(adapter->vdev, sta_mac->bytes);
+		vdev = hdd_objmgr_get_vdev(adapter);
+		if (vdev) {
+			p2p_peer_authorized(vdev, sta_mac->bytes);
+			hdd_objmgr_put_vdev(vdev);
+		} else {
+			hdd_err("vdev is NULL");
+		}
 	}
 
 	hdd_put_sta_info_ref(&adapter->sta_info_list, &sta_info, true);