Browse Source

qcacld-3.0: Possible NULL pointer dereference in pmo

Currently, the return value of get_wmi_unified_hdl_from_psoc() API
is passing directly as argument to some functions without checking
the return value for NULL which may cause NULL pointer dereference.

To address this issue, add NULL checks for return value of
get_wmi_unified_hdl_from_psoc() API where ever it is getting used.

Change-id: I60e89b5305ad31d8663a8feed3cb0f71105bb060
CRs-Fixed: 2316868
Dundi Raviteja 6 years ago
parent
commit
db2dbab047

+ 11 - 5
components/target_if/pmo/src/target_if_pmo_arp.c

@@ -34,6 +34,7 @@ QDF_STATUS target_if_pmo_send_arp_offload_req(
 	uint8_t vdev_id;
 	struct wlan_objmgr_psoc *psoc;
 	QDF_STATUS status;
+	wmi_unified_t wmi_handle;
 
 	if (!vdev) {
 		target_if_err("vdev ptr passed is NULL");
@@ -47,11 +48,16 @@ QDF_STATUS target_if_pmo_send_arp_offload_req(
 		return QDF_STATUS_E_INVAL;
 	}
 
-	status = wmi_unified_enable_arp_ns_offload_cmd(
-			get_wmi_unified_hdl_from_psoc(psoc),
-			arp_offload_req,
-			ns_offload_req,
-			vdev_id);
+	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
+	if (!wmi_handle) {
+		target_if_err("Invalid wmi handle");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	status = wmi_unified_enable_arp_ns_offload_cmd(wmi_handle,
+						       arp_offload_req,
+						       ns_offload_req,
+						       vdev_id);
 	if (status != QDF_STATUS_SUCCESS)
 		target_if_err("Failed to enable ARP NDP/NSffload");
 

+ 31 - 10
components/target_if/pmo/src/target_if_pmo_gtk.c

@@ -33,6 +33,7 @@ QDF_STATUS target_if_pmo_send_gtk_offload_req(struct wlan_objmgr_vdev *vdev,
 	QDF_STATUS status;
 	uint32_t gtk_offload_opcode;
 	struct wlan_objmgr_psoc *psoc;
+	wmi_unified_t wmi_handle;
 
 	if (!vdev) {
 		target_if_err("vdev ptr passed is NULL");
@@ -51,12 +52,17 @@ QDF_STATUS target_if_pmo_send_gtk_offload_req(struct wlan_objmgr_vdev *vdev,
 	else
 		gtk_offload_opcode = GTK_OFFLOAD_DISABLE_OPCODE;
 
-	status = wmi_unified_send_gtk_offload_cmd(
-			get_wmi_unified_hdl_from_psoc(psoc),
-			vdev_id,
-			gtk_req,
-			gtk_req->flags,
-			gtk_offload_opcode);
+	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
+	if (!wmi_handle) {
+		target_if_err("Invalid wmi handle");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	status = wmi_unified_send_gtk_offload_cmd(wmi_handle,
+						  vdev_id,
+						  gtk_req,
+						  gtk_req->flags,
+						  gtk_offload_opcode);
 	if (status)
 		target_if_err("Failed to send gtk offload cmd to fw");
 
@@ -69,6 +75,7 @@ QDF_STATUS target_if_pmo_send_gtk_response_req(struct wlan_objmgr_vdev *vdev)
 	struct wlan_objmgr_psoc *psoc;
 	QDF_STATUS status = QDF_STATUS_SUCCESS;
 	uint32_t offload_req_opcode;
+	wmi_unified_t wmi_handle;
 
 	if (!vdev) {
 		target_if_err("vdev ptr passed is NULL");
@@ -85,9 +92,14 @@ QDF_STATUS target_if_pmo_send_gtk_response_req(struct wlan_objmgr_vdev *vdev)
 	/* Request for GTK offload status */
 	offload_req_opcode = GTK_OFFLOAD_REQUEST_STATUS_OPCODE;
 
+	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
+	if (!wmi_handle) {
+		target_if_err("Invalid wmi handle");
+		return QDF_STATUS_E_INVAL;
+	}
+
 	/* send the wmi command */
-	status = wmi_unified_process_gtk_offload_getinfo_cmd(
-			get_wmi_unified_hdl_from_psoc(psoc),
+	status = wmi_unified_process_gtk_offload_getinfo_cmd(wmi_handle,
 			vdev_id, offload_req_opcode);
 
 	return status;
@@ -99,6 +111,7 @@ int target_if_pmo_gtk_offload_status_event(void *scn_handle,
 	struct pmo_gtk_rsp_params *gtk_rsp_param;
 	struct wlan_objmgr_psoc *psoc;
 	QDF_STATUS ret;
+	wmi_unified_t wmi_handle;
 
 	TARGET_IF_ENTER();
 	psoc = target_if_get_psoc_from_scn_hdl(scn_handle);
@@ -115,8 +128,16 @@ int target_if_pmo_gtk_offload_status_event(void *scn_handle,
 		goto out;
 	}
 
-	if (wmi_extract_gtk_rsp_event(get_wmi_unified_hdl_from_psoc(psoc),
-			event, gtk_rsp_param, len) != QDF_STATUS_SUCCESS) {
+	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
+	if (!wmi_handle) {
+		target_if_err("Invalid wmi handle");
+		qdf_mem_free(gtk_rsp_param);
+		ret = -EINVAL;
+		goto out;
+	}
+
+	if (wmi_extract_gtk_rsp_event(wmi_handle, event, gtk_rsp_param, len) !=
+				      QDF_STATUS_SUCCESS) {
 		target_if_err("Extraction of gtk rsp event failed");
 		qdf_mem_free(gtk_rsp_param);
 		ret = -EINVAL;

+ 8 - 3
components/target_if/pmo/src/target_if_pmo_hw_filter.c

@@ -31,15 +31,20 @@ QDF_STATUS target_if_pmo_conf_hw_filter(struct wlan_objmgr_psoc *psoc,
 					struct pmo_hw_filter_params *req)
 {
 	QDF_STATUS status;
+	wmi_unified_t wmi_handle;
 
 	if (!psoc) {
 		target_if_err("psoc is NULL");
 		return QDF_STATUS_E_INVAL;
 	}
 
-	status = wmi_unified_conf_hw_filter_cmd(
-		get_wmi_unified_hdl_from_psoc(psoc),
-		req);
+	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
+	if (!wmi_handle) {
+		target_if_err("Invalid wmi handle");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	status = wmi_unified_conf_hw_filter_cmd(wmi_handle, req);
 
 	if (QDF_IS_STATUS_ERROR(status))
 		target_if_err("Failed to configure HW Filter");

+ 45 - 15
components/target_if/pmo/src/target_if_pmo_lphb.c

@@ -33,6 +33,7 @@ QDF_STATUS target_if_pmo_send_lphb_enable(struct wlan_objmgr_psoc *psoc,
 	QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
 	int status = 0;
 	wmi_hb_set_enable_cmd_fixed_param hb_enable_fp;
+	wmi_unified_t wmi_handle;
 
 	if (ts_lphb_enable == NULL) {
 		target_if_err("LPHB Enable configuration is NULL");
@@ -55,9 +56,14 @@ QDF_STATUS target_if_pmo_send_lphb_enable(struct wlan_objmgr_psoc *psoc,
 	hb_enable_fp.item = ts_lphb_enable->item;
 	hb_enable_fp.session = ts_lphb_enable->session;
 
-	status = wmi_unified_lphb_config_hbenable_cmd(
-			get_wmi_unified_hdl_from_psoc(psoc),
-			&hb_enable_fp);
+	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
+	if (!wmi_handle) {
+		target_if_err("Invalid wmi handle");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	status = wmi_unified_lphb_config_hbenable_cmd(wmi_handle,
+						      &hb_enable_fp);
 	if (status != EOK) {
 		qdf_status = QDF_STATUS_E_FAILURE;
 		goto error;
@@ -74,6 +80,7 @@ QDF_STATUS target_if_pmo_send_lphb_tcp_params(struct wlan_objmgr_psoc *psoc,
 	QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
 	int status = 0;
 	wmi_hb_set_tcp_params_cmd_fixed_param hb_tcp_params_fp = {0};
+	wmi_unified_t wmi_handle;
 
 	if (ts_lphb_tcp_param == NULL) {
 		target_if_err("TCP params LPHB configuration is NULL");
@@ -103,9 +110,14 @@ QDF_STATUS target_if_pmo_send_lphb_tcp_params(struct wlan_objmgr_psoc *psoc,
 	WMI_CHAR_ARRAY_TO_MAC_ADDR(ts_lphb_tcp_param->gateway_mac.bytes,
 				   &hb_tcp_params_fp.gateway_mac);
 
-	status = wmi_unified_lphb_config_tcp_params_cmd(
-			get_wmi_unified_hdl_from_psoc(psoc),
-			&hb_tcp_params_fp);
+	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
+	if (!wmi_handle) {
+		target_if_err("Invalid wmi handle");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	status = wmi_unified_lphb_config_tcp_params_cmd(wmi_handle,
+							&hb_tcp_params_fp);
 	if (status != EOK) {
 		qdf_status = QDF_STATUS_E_FAILURE;
 		goto error;
@@ -122,6 +134,7 @@ QDF_STATUS target_if_pmo_send_lphb_tcp_pkt_filter(struct wlan_objmgr_psoc *psoc,
 	QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
 	int status = 0;
 	wmi_hb_set_tcp_pkt_filter_cmd_fixed_param hb_tcp_filter_fp = {0};
+	wmi_unified_t wmi_handle;
 
 	if (ts_lphb_tcp_filter == NULL) {
 		target_if_err("TCP PKT FILTER LPHB configuration is NULL");
@@ -145,9 +158,14 @@ QDF_STATUS target_if_pmo_send_lphb_tcp_pkt_filter(struct wlan_objmgr_psoc *psoc,
 	       (void *)&ts_lphb_tcp_filter->filter,
 	       WMI_WLAN_HB_MAX_FILTER_SIZE);
 
-	status = wmi_unified_lphb_config_tcp_pkt_filter_cmd(
-			get_wmi_unified_hdl_from_psoc(psoc),
-			&hb_tcp_filter_fp);
+	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
+	if (!wmi_handle) {
+		target_if_err("Invalid wmi handle");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	status = wmi_unified_lphb_config_tcp_pkt_filter_cmd(wmi_handle,
+							    &hb_tcp_filter_fp);
 	if (status != EOK) {
 		qdf_status = QDF_STATUS_E_FAILURE;
 		goto error;
@@ -164,6 +182,7 @@ QDF_STATUS target_if_pmo_send_lphb_udp_params(struct wlan_objmgr_psoc *psoc,
 	QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
 	int status = 0;
 	wmi_hb_set_udp_params_cmd_fixed_param hb_udp_params_fp = {0};
+	wmi_unified_t wmi_handle;
 
 	if (ts_lphb_udp_param == NULL) {
 		target_if_err("UDP param for LPHB configuration is NULL");
@@ -191,9 +210,14 @@ QDF_STATUS target_if_pmo_send_lphb_udp_params(struct wlan_objmgr_psoc *psoc,
 	WMI_CHAR_ARRAY_TO_MAC_ADDR(ts_lphb_udp_param->gateway_mac.bytes,
 				   &hb_udp_params_fp.gateway_mac);
 
-	status = wmi_unified_lphb_config_udp_params_cmd(
-			get_wmi_unified_hdl_from_psoc(psoc),
-			&hb_udp_params_fp);
+	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
+	if (!wmi_handle) {
+		target_if_err("Invalid wmi handle");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	status = wmi_unified_lphb_config_udp_params_cmd(wmi_handle,
+							&hb_udp_params_fp);
 	if (status != EOK) {
 		qdf_status = QDF_STATUS_E_FAILURE;
 		goto error;
@@ -217,6 +241,7 @@ QDF_STATUS target_if_pmo_send_lphb_udp_pkt_filter(struct wlan_objmgr_psoc *psoc,
 	QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
 	int status = 0;
 	wmi_hb_set_udp_pkt_filter_cmd_fixed_param hb_udp_filter_fp = {0};
+	wmi_unified_t wmi_handle;
 
 	if (ts_lphb_udp_filter == NULL) {
 		target_if_err("LPHB UDP packet filter configuration is NULL");
@@ -240,9 +265,14 @@ QDF_STATUS target_if_pmo_send_lphb_udp_pkt_filter(struct wlan_objmgr_psoc *psoc,
 	       (void *)&ts_lphb_udp_filter->filter,
 	       WMI_WLAN_HB_MAX_FILTER_SIZE);
 
-	status = wmi_unified_lphb_config_udp_pkt_filter_cmd(
-			get_wmi_unified_hdl_from_psoc(psoc),
-			&hb_udp_filter_fp);
+	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
+	if (!wmi_handle) {
+		target_if_err("Invalid wmi handle");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	status = wmi_unified_lphb_config_udp_pkt_filter_cmd(wmi_handle,
+							    &hb_udp_filter_fp);
 	if (status != EOK) {
 		qdf_status = QDF_STATUS_E_FAILURE;
 		goto error;

+ 44 - 17
components/target_if/pmo/src/target_if_pmo_mc_addr_filtering.c

@@ -34,6 +34,7 @@ QDF_STATUS target_if_pmo_set_mc_filter_req(
 	uint8_t vdev_id;
 	struct wlan_objmgr_psoc *psoc;
 	QDF_STATUS status;
+	wmi_unified_t wmi_handle;
 
 	if (!vdev) {
 		target_if_err("vdev ptr passed is NULL");
@@ -47,10 +48,14 @@ QDF_STATUS target_if_pmo_set_mc_filter_req(
 		return QDF_STATUS_E_INVAL;
 	}
 
-	status = wmi_unified_add_clear_mcbc_filter_cmd(
-			get_wmi_unified_hdl_from_psoc(psoc),
-			vdev_id,
-			multicast_addr, false);
+	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
+	if (!wmi_handle) {
+		target_if_err("Invalid wmi handle");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	status = wmi_unified_add_clear_mcbc_filter_cmd(wmi_handle, vdev_id,
+						       multicast_addr, false);
 	if (status)
 		target_if_err("Failed to send add/clear mcbc filter cmd");
 
@@ -64,6 +69,7 @@ QDF_STATUS target_if_pmo_clear_mc_filter_req(
 	uint8_t vdev_id;
 	struct wlan_objmgr_psoc *psoc;
 	QDF_STATUS status;
+	wmi_unified_t wmi_handle;
 
 	if (!vdev) {
 		target_if_err("vdev ptr passed is NULL");
@@ -77,10 +83,14 @@ QDF_STATUS target_if_pmo_clear_mc_filter_req(
 		return QDF_STATUS_E_INVAL;
 	}
 
-	status = wmi_unified_add_clear_mcbc_filter_cmd(
-			get_wmi_unified_hdl_from_psoc(psoc),
-			vdev_id,
-			multicast_addr, true);
+	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
+	if (!wmi_handle) {
+		target_if_err("Invalid wmi handle");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	status = wmi_unified_add_clear_mcbc_filter_cmd(wmi_handle, vdev_id,
+						       multicast_addr, true);
 	if (status)
 		target_if_err("Failed to send add/clear mcbc filter cmd");
 
@@ -93,8 +103,13 @@ bool target_if_pmo_get_multiple_mc_filter_support(
 {
 	wmi_unified_t wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
 
+	if (!wmi_handle) {
+		target_if_err("Invalid wmi handle");
+		return false;
+	}
+
 	return wmi_service_enabled(wmi_handle,
-				      wmi_service_multiple_mcast_filter_set);
+				   wmi_service_multiple_mcast_filter_set);
 }
 
 QDF_STATUS target_if_pmo_set_multiple_mc_filter_req(
@@ -105,6 +120,7 @@ QDF_STATUS target_if_pmo_set_multiple_mc_filter_req(
 	struct wlan_objmgr_psoc *psoc;
 	struct pmo_mcast_filter_params filter_params;
 	QDF_STATUS status;
+	wmi_unified_t wmi_handle;
 
 	if (!vdev) {
 		target_if_err("vdev ptr passed is NULL");
@@ -125,10 +141,15 @@ QDF_STATUS target_if_pmo_set_multiple_mc_filter_req(
 	/* add one/multiple mc list */
 	filter_params.action = 1;
 
-	status = wmi_unified_multiple_add_clear_mcbc_filter_cmd(
-			get_wmi_unified_hdl_from_psoc(psoc),
-			vdev_id,
-			&filter_params);
+	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
+	if (!wmi_handle) {
+		target_if_err("Invalid wmi handle");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	status = wmi_unified_multiple_add_clear_mcbc_filter_cmd(wmi_handle,
+								vdev_id,
+								&filter_params);
 	if (status)
 		target_if_err("Failed to send add/clear mcbc filter cmd");
 
@@ -143,6 +164,7 @@ QDF_STATUS target_if_pmo_clear_multiple_mc_filter_req(
 	struct wlan_objmgr_psoc *psoc;
 	struct pmo_mcast_filter_params filter_params;
 	QDF_STATUS status;
+	wmi_unified_t wmi_handle;
 
 	if (!vdev) {
 		target_if_err("vdev ptr passed is NULL");
@@ -163,10 +185,15 @@ QDF_STATUS target_if_pmo_clear_multiple_mc_filter_req(
 	/* delete one/multiple mc list */
 	filter_params.action = 0;
 
-	status = wmi_unified_multiple_add_clear_mcbc_filter_cmd(
-			get_wmi_unified_hdl_from_psoc(psoc),
-			vdev_id,
-			&filter_params);
+	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
+	if (!wmi_handle) {
+		target_if_err("Invalid wmi handle");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	status = wmi_unified_multiple_add_clear_mcbc_filter_cmd(wmi_handle,
+								vdev_id,
+								&filter_params);
 	if (status)
 		target_if_err("Failed to send add/clear mcbc filter cmd");
 

+ 11 - 5
components/target_if/pmo/src/target_if_pmo_ns.c

@@ -34,6 +34,7 @@ QDF_STATUS target_if_pmo_send_ns_offload_req(
 	uint8_t vdev_id;
 	struct wlan_objmgr_psoc *psoc;
 	QDF_STATUS status;
+	wmi_unified_t wmi_handle;
 
 	if (!vdev) {
 		target_if_err("vdev ptr passed is NULL");
@@ -47,11 +48,16 @@ QDF_STATUS target_if_pmo_send_ns_offload_req(
 		return QDF_STATUS_E_INVAL;
 	}
 
-	status = wmi_unified_enable_arp_ns_offload_cmd(
-			get_wmi_unified_hdl_from_psoc(psoc),
-			arp_offload_req,
-			ns_offload_req,
-			vdev_id);
+	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
+	if (!wmi_handle) {
+		target_if_err("Invalid wmi handle");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	status = wmi_unified_enable_arp_ns_offload_cmd(wmi_handle,
+						       arp_offload_req,
+						       ns_offload_req,
+						       vdev_id);
 	if (status != QDF_STATUS_SUCCESS)
 		target_if_err("Failed to enable ARP NDP/NSffload");
 

+ 19 - 8
components/target_if/pmo/src/target_if_pmo_pkt_filter.c

@@ -33,6 +33,7 @@ QDF_STATUS target_if_pmo_send_pkt_filter_req(struct wlan_objmgr_vdev *vdev,
 	uint8_t vdev_id;
 	struct wlan_objmgr_psoc *psoc;
 	QDF_STATUS status;
+	wmi_unified_t wmi_handle;
 
 	if (!vdev) {
 		target_if_err("vdev ptr passed is NULL");
@@ -46,9 +47,14 @@ QDF_STATUS target_if_pmo_send_pkt_filter_req(struct wlan_objmgr_vdev *vdev,
 		return QDF_STATUS_E_INVAL;
 	}
 
+	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
+	if (!wmi_handle) {
+		target_if_err("Invalid wmi handle");
+		return QDF_STATUS_E_INVAL;
+	}
+
 	/* send the command along with data */
-	status = wmi_unified_config_packet_filter_cmd(
-			get_wmi_unified_hdl_from_psoc(psoc), vdev_id,
+	status = wmi_unified_config_packet_filter_cmd(wmi_handle, vdev_id,
 			rcv_filter_param,
 			rcv_filter_param->filter_id, true);
 	if (status) {
@@ -57,9 +63,8 @@ QDF_STATUS target_if_pmo_send_pkt_filter_req(struct wlan_objmgr_vdev *vdev,
 	}
 
 	/* Enable packet filter */
-	status = wmi_unified_enable_disable_packet_filter_cmd(
-			get_wmi_unified_hdl_from_psoc(psoc),
-			vdev_id, true);
+	status = wmi_unified_enable_disable_packet_filter_cmd(wmi_handle,
+							      vdev_id, true);
 	if (status)
 		target_if_err("Failed to send packet filter wmi cmd to fw");
 
@@ -72,6 +77,7 @@ QDF_STATUS target_if_pmo_clear_pkt_filter_req(struct wlan_objmgr_vdev *vdev,
 	uint8_t vdev_id;
 	struct wlan_objmgr_psoc *psoc;
 	QDF_STATUS status;
+	wmi_unified_t wmi_handle;
 
 	if (!vdev) {
 		target_if_err("vdev ptr passed is NULL");
@@ -85,10 +91,15 @@ QDF_STATUS target_if_pmo_clear_pkt_filter_req(struct wlan_objmgr_vdev *vdev,
 		return QDF_STATUS_E_INVAL;
 	}
 
+	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
+	if (!wmi_handle) {
+		target_if_err("Invalid wmi handle");
+		return QDF_STATUS_E_INVAL;
+	}
+
 	/* send the command along with data */
-	status = wmi_unified_config_packet_filter_cmd(
-			get_wmi_unified_hdl_from_psoc(psoc), vdev_id,
-			NULL, rcv_clear_param->filter_id, false);
+	status = wmi_unified_config_packet_filter_cmd(wmi_handle, vdev_id, NULL,
+					rcv_clear_param->filter_id, false);
 
 	if (status)
 		target_if_err("Failed to clear filter cmd");

+ 29 - 7
components/target_if/pmo/src/target_if_pmo_static_config.c

@@ -33,6 +33,7 @@ QDF_STATUS target_if_pmo_send_ra_filter_req(struct wlan_objmgr_vdev *vdev,
 	uint8_t vdev_id;
 	struct wlan_objmgr_psoc *psoc;
 	QDF_STATUS status;
+	wmi_unified_t wmi_handle;
 
 	if (!vdev) {
 		target_if_err("vdev ptr passed is NULL");
@@ -46,9 +47,16 @@ QDF_STATUS target_if_pmo_send_ra_filter_req(struct wlan_objmgr_vdev *vdev,
 		return QDF_STATUS_E_INVAL;
 	}
 
-	status = wmi_unified_wow_sta_ra_filter_cmd(
-			get_wmi_unified_hdl_from_psoc(psoc), vdev_id,
-			default_pattern, rate_limit_interval);
+	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
+	if (!wmi_handle) {
+		target_if_err("Invalid wmi handle");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	status = wmi_unified_wow_sta_ra_filter_cmd(wmi_handle,
+						   vdev_id,
+						   default_pattern,
+						   rate_limit_interval);
 	if (status)
 		target_if_err("Failed to send RA rate limit to fw");
 
@@ -62,6 +70,7 @@ QDF_STATUS target_if_pmo_send_action_frame_patterns(
 	uint8_t vdev_id;
 	struct wlan_objmgr_psoc *psoc;
 	QDF_STATUS status;
+	wmi_unified_t wmi_handle;
 
 	if (!vdev) {
 		target_if_err("vdev ptr passed is NULL");
@@ -75,8 +84,13 @@ QDF_STATUS target_if_pmo_send_action_frame_patterns(
 		return QDF_STATUS_E_INVAL;
 	}
 
-	status = wmi_unified_action_frame_patterns_cmd(
-			get_wmi_unified_hdl_from_psoc(psoc), ip_cmd);
+	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
+	if (!wmi_handle) {
+		target_if_err("Invalid wmi handle");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	status = wmi_unified_action_frame_patterns_cmd(wmi_handle, ip_cmd);
 	if (status != QDF_STATUS_SUCCESS)
 		target_if_err("Failed to config wow action frame map, ret %d",
 			status);
@@ -90,6 +104,7 @@ QDF_STATUS target_if_pmo_send_enhance_mc_offload_req(
 	uint8_t vdev_id;
 	struct wlan_objmgr_psoc *psoc;
 	QDF_STATUS status;
+	wmi_unified_t wmi_handle;
 
 	if (!vdev) {
 		target_if_err("vdev ptr passed is NULL");
@@ -103,8 +118,15 @@ QDF_STATUS target_if_pmo_send_enhance_mc_offload_req(
 		return QDF_STATUS_E_INVAL;
 	}
 
-	status = wmi_unified_enable_enhance_multicast_offload_cmd(
-			get_wmi_unified_hdl_from_psoc(psoc), vdev_id, enable);
+	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
+	if (!wmi_handle) {
+		target_if_err("Invalid wmi handle");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	status = wmi_unified_enable_enhance_multicast_offload_cmd(wmi_handle,
+								  vdev_id,
+								  enable);
 	if (status)
 		target_if_err("Failed to config wow wakeup event");
 

+ 128 - 30
components/target_if/pmo/src/target_if_pmo_suspend_resume.c

@@ -36,6 +36,7 @@ QDF_STATUS target_if_pmo_send_vdev_update_param_req(
 	uint8_t vdev_id;
 	struct wlan_objmgr_psoc *psoc;
 	struct vdev_set_params param = {0};
+	wmi_unified_t wmi_handle;
 
 	if (!vdev) {
 		target_if_err("vdev ptr passed is NULL");
@@ -61,13 +62,18 @@ QDF_STATUS target_if_pmo_send_vdev_update_param_req(
 		return QDF_STATUS_E_INVAL;
 	}
 
+	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
+	if (!wmi_handle) {
+		target_if_err("Invalid wmi handle");
+		return QDF_STATUS_E_INVAL;
+	}
+
 	param.if_id = vdev_id;
 	param.param_id = param_id;
 	param.param_value = param_value;
 	target_if_debug("set vdev param vdev_id: %d value: %d for param_id: %d",
 			vdev_id, param_value, param_id);
-	return wmi_unified_vdev_set_param_send(
-			get_wmi_unified_hdl_from_psoc(psoc), &param);
+	return wmi_unified_vdev_set_param_send(wmi_handle, &param);
 }
 
 QDF_STATUS target_if_pmo_send_vdev_ps_param_req(
@@ -79,6 +85,7 @@ QDF_STATUS target_if_pmo_send_vdev_ps_param_req(
 	struct wlan_objmgr_psoc *psoc;
 	QDF_STATUS status;
 	struct sta_ps_params sta_ps_param = {0};
+	wmi_unified_t wmi_handle;
 
 	if (!vdev) {
 		target_if_err("vdev ptr passed is NULL");
@@ -107,100 +114,191 @@ QDF_STATUS target_if_pmo_send_vdev_ps_param_req(
 	target_if_debug("set vdev param vdev_id: %d value: %d for param_id: %d",
 			vdev_id, param_value, param_id);
 
-	status = wmi_unified_sta_ps_cmd_send(
-			get_wmi_unified_hdl_from_psoc(psoc), &sta_ps_param);
+	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
+	if (!wmi_handle) {
+		target_if_err("Invalid wmi handle");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	status = wmi_unified_sta_ps_cmd_send(wmi_handle, &sta_ps_param);
 	if (QDF_IS_STATUS_ERROR(status))
 		return status;
 
 	return status;
-
 }
 
 void target_if_pmo_psoc_update_bus_suspend(struct wlan_objmgr_psoc *psoc,
 		uint8_t value)
 {
-	wmi_set_is_wow_bus_suspended(
-			get_wmi_unified_hdl_from_psoc(psoc), value);
+	wmi_unified_t wmi_handle;
+
+	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
+	if (!wmi_handle) {
+		target_if_err("Invalid wmi handle");
+		return;
+	}
+
+	wmi_set_is_wow_bus_suspended(wmi_handle, value);
 }
 
 int target_if_pmo_psoc_get_host_credits(struct wlan_objmgr_psoc *psoc)
 {
-	return wmi_get_host_credits(get_wmi_unified_hdl_from_psoc(psoc));
+	wmi_unified_t wmi_handle;
+
+	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
+	if (!wmi_handle) {
+		target_if_err("Invalid wmi handle");
+		return 0;
+	}
+
+	return wmi_get_host_credits(wmi_handle);
 }
 
 int target_if_pmo_psoc_get_pending_cmnds(struct wlan_objmgr_psoc *psoc)
 {
-	return wmi_get_pending_cmds(get_wmi_unified_hdl_from_psoc(psoc));
+	wmi_unified_t wmi_handle;
+
+	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
+	if (!wmi_handle) {
+		target_if_err("Invalid wmi handle");
+		return 0;
+	}
+
+	return wmi_get_pending_cmds(wmi_handle);
 }
 
 void target_if_pmo_update_target_suspend_flag(struct wlan_objmgr_psoc *psoc,
 		uint8_t value)
 {
-	wmi_set_target_suspend(get_wmi_unified_hdl_from_psoc(psoc), value);
+	wmi_unified_t wmi_handle;
+
+	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
+	if (!wmi_handle) {
+		target_if_err("Invalid wmi handle");
+		return;
+	}
+
+	wmi_set_target_suspend(wmi_handle, value);
 }
 
 QDF_STATUS target_if_pmo_psoc_send_wow_enable_req(
 		struct wlan_objmgr_psoc *psoc,
 		struct pmo_wow_cmd_params *param)
 {
+	wmi_unified_t wmi_handle;
+
+	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
+	if (!wmi_handle) {
+		target_if_err("Invalid wmi handle");
+		return QDF_STATUS_E_INVAL;
+	}
+
 	wma_check_and_set_wake_timer(SIR_INSTALL_KEY_TIMEOUT_MS);
-	return wmi_unified_wow_enable_send(get_wmi_unified_hdl_from_psoc(psoc),
-			(struct wow_cmd_params *)param,
-			TGT_WILDCARD_PDEV_ID);
+	return wmi_unified_wow_enable_send(wmi_handle,
+					   (struct wow_cmd_params *)param,
+					   TGT_WILDCARD_PDEV_ID);
 }
 
 QDF_STATUS target_if_pmo_psoc_send_suspend_req(
 		struct wlan_objmgr_psoc *psoc,
 		struct pmo_suspend_params *param)
 {
-	return wmi_unified_suspend_send(get_wmi_unified_hdl_from_psoc(psoc),
-			(struct suspend_params *) param,
-			TGT_WILDCARD_PDEV_ID);
+	wmi_unified_t wmi_handle;
+
+	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
+	if (!wmi_handle) {
+		target_if_err("Invalid wmi handle");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	return wmi_unified_suspend_send(wmi_handle,
+					(struct suspend_params *) param,
+					TGT_WILDCARD_PDEV_ID);
 }
 
 void target_if_pmo_set_runtime_pm_in_progress(struct wlan_objmgr_psoc *psoc,
 					      bool value)
 {
-	return wmi_set_runtime_pm_inprogress(
-			get_wmi_unified_hdl_from_psoc(psoc), value);
+	wmi_unified_t wmi_handle;
+
+	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
+	if (!wmi_handle) {
+		target_if_err("Invalid wmi handle");
+		return;
+	}
+
+	return wmi_set_runtime_pm_inprogress(wmi_handle, value);
 }
 
 bool target_if_pmo_get_runtime_pm_in_progress(
 		struct wlan_objmgr_psoc *psoc)
 {
-	return wmi_get_runtime_pm_inprogress(
-			get_wmi_unified_hdl_from_psoc(psoc));
+	wmi_unified_t wmi_handle;
+
+	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
+	if (!wmi_handle) {
+		target_if_err("Invalid wmi handle");
+		return false;
+	}
+
+	return wmi_get_runtime_pm_inprogress(wmi_handle);
 }
 
 QDF_STATUS target_if_pmo_psoc_send_host_wakeup_ind(
 		struct wlan_objmgr_psoc *psoc)
 {
-	return wmi_unified_host_wakeup_ind_to_fw_cmd(
-			get_wmi_unified_hdl_from_psoc(psoc));
+	wmi_unified_t wmi_handle;
+
+	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
+	if (!wmi_handle) {
+		target_if_err("Invalid wmi handle");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	return wmi_unified_host_wakeup_ind_to_fw_cmd(wmi_handle);
 }
 
 QDF_STATUS target_if_pmo_psoc_send_target_resume_req(
 		struct wlan_objmgr_psoc *psoc)
 {
-	return wmi_unified_resume_send(get_wmi_unified_hdl_from_psoc(psoc),
-					TGT_WILDCARD_PDEV_ID);
+	wmi_unified_t wmi_handle;
+
+	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
+	if (!wmi_handle) {
+		target_if_err("Invalid wmi handle");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	return wmi_unified_resume_send(wmi_handle, TGT_WILDCARD_PDEV_ID);
 }
 
 #ifdef FEATURE_WLAN_D0WOW
 QDF_STATUS target_if_pmo_psoc_send_d0wow_enable_req(
 		struct wlan_objmgr_psoc *psoc)
 {
-	return wmi_unified_d0wow_enable_send(
-			get_wmi_unified_hdl_from_psoc(psoc),
-			TGT_WILDCARD_PDEV_ID);
+	wmi_unified_t wmi_handle;
+
+	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
+	if (!wmi_handle) {
+		target_if_err("Invalid wmi handle");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	return wmi_unified_d0wow_enable_send(wmi_handle, TGT_WILDCARD_PDEV_ID);
 }
 
 QDF_STATUS target_if_pmo_psoc_send_d0wow_disable_req(
 		struct wlan_objmgr_psoc *psoc)
 {
-	return wmi_unified_d0wow_disable_send(
-			get_wmi_unified_hdl_from_psoc(psoc),
-			TGT_WILDCARD_PDEV_ID);
+	wmi_unified_t wmi_handle;
+
+	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
+	if (!wmi_handle) {
+		target_if_err("Invalid wmi handle");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	return wmi_unified_d0wow_disable_send(wmi_handle, TGT_WILDCARD_PDEV_ID);
 }
 #else
 QDF_STATUS target_if_pmo_psoc_send_d0wow_enable_req(

+ 38 - 14
components/target_if/pmo/src/target_if_pmo_wow.c

@@ -33,6 +33,7 @@ QDF_STATUS target_if_pmo_enable_wow_wakeup_event(struct wlan_objmgr_vdev *vdev,
 	uint8_t vdev_id;
 	struct wlan_objmgr_psoc *psoc;
 	QDF_STATUS status;
+	wmi_unified_t wmi_handle;
 
 	if (!vdev) {
 		target_if_err("vdev ptr passed is NULL");
@@ -46,9 +47,14 @@ QDF_STATUS target_if_pmo_enable_wow_wakeup_event(struct wlan_objmgr_vdev *vdev,
 		return QDF_STATUS_E_INVAL;
 	}
 
-	status = wmi_unified_add_wow_wakeup_event_cmd(
-			get_wmi_unified_hdl_from_psoc(psoc),
-			vdev_id, bitmap, true);
+	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
+	if (!wmi_handle) {
+		target_if_err("Invalid wmi handle");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	status = wmi_unified_add_wow_wakeup_event_cmd(wmi_handle, vdev_id,
+						      bitmap, true);
 	if (status)
 		target_if_err("Failed to config wow wakeup event");
 
@@ -61,6 +67,7 @@ QDF_STATUS target_if_pmo_disable_wow_wakeup_event(struct wlan_objmgr_vdev *vdev,
 	uint8_t vdev_id;
 	struct wlan_objmgr_psoc *psoc;
 	QDF_STATUS status;
+	wmi_unified_t wmi_handle;
 
 	if (!vdev) {
 		target_if_err("vdev ptr passed is NULL");
@@ -74,9 +81,14 @@ QDF_STATUS target_if_pmo_disable_wow_wakeup_event(struct wlan_objmgr_vdev *vdev,
 		return QDF_STATUS_E_INVAL;
 	}
 
-	status = wmi_unified_add_wow_wakeup_event_cmd(
-			get_wmi_unified_hdl_from_psoc(psoc),
-			vdev_id, bitmap, false);
+	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
+	if (!wmi_handle) {
+		target_if_err("Invalid wmi handle");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	status = wmi_unified_add_wow_wakeup_event_cmd(wmi_handle, vdev_id,
+						      bitmap, false);
 	if (status)
 		target_if_err("Failed to config wow wakeup event");
 
@@ -92,6 +104,7 @@ QDF_STATUS target_if_pmo_send_wow_patterns_to_fw(struct wlan_objmgr_vdev *vdev,
 	uint8_t vdev_id;
 	struct wlan_objmgr_psoc *psoc;
 	QDF_STATUS status;
+	wmi_unified_t wmi_handle;
 
 	if (!vdev) {
 		target_if_err("vdev ptr passed is NULL");
@@ -105,11 +118,16 @@ QDF_STATUS target_if_pmo_send_wow_patterns_to_fw(struct wlan_objmgr_vdev *vdev,
 		return QDF_STATUS_E_INVAL;
 	}
 
-	status = wmi_unified_wow_patterns_to_fw_cmd(
-				get_wmi_unified_hdl_from_psoc(psoc),
-				vdev_id, ptrn_id, ptrn,
-				ptrn_len, ptrn_offset, mask,
-				mask_len, user, 0);
+	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
+	if (!wmi_handle) {
+		target_if_err("Invalid wmi handle");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	status = wmi_unified_wow_patterns_to_fw_cmd(wmi_handle,
+						    vdev_id, ptrn_id, ptrn,
+						    ptrn_len, ptrn_offset,
+						    mask, mask_len, user, 0);
 
 	return status;
 }
@@ -120,6 +138,7 @@ QDF_STATUS target_if_pmo_del_wow_patterns_to_fw(struct wlan_objmgr_vdev *vdev,
 	uint8_t vdev_id;
 	struct wlan_objmgr_psoc *psoc;
 	QDF_STATUS status;
+	wmi_unified_t wmi_handle;
 
 	if (!vdev) {
 		target_if_err("vdev ptr passed is NULL");
@@ -133,9 +152,14 @@ QDF_STATUS target_if_pmo_del_wow_patterns_to_fw(struct wlan_objmgr_vdev *vdev,
 		return QDF_STATUS_E_INVAL;
 	}
 
-	status = wmi_unified_wow_delete_pattern_cmd(
-				get_wmi_unified_hdl_from_psoc(psoc), ptrn_id,
-				vdev_id);
+	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
+	if (!wmi_handle) {
+		target_if_err("Invalid wmi handle");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	status = wmi_unified_wow_delete_pattern_cmd(wmi_handle, ptrn_id,
+						    vdev_id);
 
 	return status;
 }