qca-wifi: Free buffer in case of error in sending wmi cmd

Free the buffer used to send wmi handle in wmi_unified_cmd_send
in case of error in sending the commands

Change-Id: I83fef6ea16e6676584196855fa327537b9e492eb
CRs-Fixed: 2427586
diff --git a/wmi/src/wmi_unified_non_tlv.c b/wmi/src/wmi_unified_non_tlv.c
index fd293f3..bae0ada 100644
--- a/wmi/src/wmi_unified_non_tlv.c
+++ b/wmi/src/wmi_unified_non_tlv.c
@@ -49,6 +49,7 @@
 {
 	wmi_vdev_create_cmd *cmd;
 	wmi_buf_t buf;
+	QDF_STATUS ret;
 	int32_t len = sizeof(wmi_vdev_create_cmd);
 
 	buf = wmi_buf_alloc(wmi_handle, len);
@@ -65,8 +66,13 @@
 		  __func__, param->vdev_id, param->type, param->subtype,
 		  macaddr[0], macaddr[1], macaddr[2],
 		  macaddr[3], macaddr[4], macaddr[5]);
-	return wmi_unified_cmd_send(wmi_handle, buf, len,
+	ret =  wmi_unified_cmd_send(wmi_handle, buf, len,
 			WMI_VDEV_CREATE_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_VDEV_CREATE_CMDID");
+		wmi_buf_free(buf);
+	}
+	return ret;
 }
 
 /**
@@ -81,6 +87,7 @@
 {
 	wmi_vdev_delete_cmd *cmd;
 	wmi_buf_t buf;
+	QDF_STATUS ret;
 	int32_t len = sizeof(wmi_vdev_delete_cmd);
 
 	buf = wmi_buf_alloc(wmi_handle, len);
@@ -91,8 +98,13 @@
 	cmd = (wmi_vdev_delete_cmd *)wmi_buf_data(buf);
 	cmd->vdev_id = if_id;
 	WMI_LOGD("%s for vap %d (%pK)", __func__, if_id, wmi_handle);
-	return wmi_unified_cmd_send(wmi_handle, buf, len,
+	ret =  wmi_unified_cmd_send(wmi_handle, buf, len,
 		WMI_VDEV_DELETE_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_VDEV_DELETE_CMDID");
+		wmi_buf_free(buf);
+	}
+	return ret;
 }
 
 /**
@@ -107,6 +119,7 @@
 {
 	wmi_vdev_stop_cmd *cmd;
 	wmi_buf_t buf;
+	QDF_STATUS ret;
 	int len = sizeof(wmi_vdev_stop_cmd);
 
 	buf = wmi_buf_alloc(wmi, len);
@@ -117,7 +130,12 @@
 	cmd = (wmi_vdev_stop_cmd *)wmi_buf_data(buf);
 	cmd->vdev_id = vdev_id;
 
-	return wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_STOP_CMDID);
+	ret =  wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_STOP_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_VDEV_STOP_CMDID");
+		wmi_buf_free(buf);
+	}
+	return ret;
 }
 
 /**
@@ -132,6 +150,7 @@
 {
 	wmi_vdev_down_cmd *cmd;
 	wmi_buf_t buf;
+	QDF_STATUS ret;
 	int len = sizeof(wmi_vdev_down_cmd);
 
 	buf = wmi_buf_alloc(wmi_handle, len);
@@ -142,7 +161,12 @@
 	cmd = (wmi_vdev_down_cmd *)wmi_buf_data(buf);
 	cmd->vdev_id = vdev_id;
 	WMI_LOGD("%s for vap %d (%pK)", __func__, vdev_id, wmi_handle);
-	return wmi_unified_cmd_send(wmi_handle, buf, len, WMI_VDEV_DOWN_CMDID);
+	ret =  wmi_unified_cmd_send(wmi_handle, buf, len, WMI_VDEV_DOWN_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_VDEV_DOWN_CMDID");
+		wmi_buf_free(buf);
+	}
+	return ret;
 }
 
 /**
@@ -158,7 +182,7 @@
 	wmi_vdev_start_request_cmd *cmd;
 	wmi_buf_t buf;
 	int len = sizeof(wmi_vdev_start_request_cmd);
-	int ret;
+	QDF_STATUS ret;
 
 	buf = wmi_buf_alloc(wmi, len);
 	if (!buf) {
@@ -207,6 +231,12 @@
 		ret =  wmi_unified_cmd_send(wmi, buf, len,
 				WMI_VDEV_START_REQUEST_CMDID);
 	}
+
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send %s", param->is_restart ? "WMI_VDEV_RESTART_REQUEST_CMDID" : "WMI_VDEV_START_REQUEST_CMDID");
+		wmi_buf_free(buf);
+	}
+
 	return ret;
 
 /*
@@ -267,6 +297,7 @@
 {
 	wmi_vdev_filter_nrp_config_cmd *cmd;
 	wmi_buf_t buf;
+	QDF_STATUS ret;
 	int len = sizeof(wmi_vdev_filter_nrp_config_cmd);
 
 	buf = wmi_buf_alloc(wmi_handle, len);
@@ -280,8 +311,13 @@
 	cmd->action = param->action;
 	cmd->type = param->type;
 	WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->addr);
-	return wmi_unified_cmd_send(wmi_handle, buf, len,
+	ret =  wmi_unified_cmd_send(wmi_handle, buf, len,
 			WMI_VDEV_FILTER_NEIGHBOR_RX_PACKETS_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_VDEV_FILTER_NEIGHBOR_RX_PACKETS_CMDID");
+		wmi_buf_free(buf);
+	}
+	return ret;
 }
 
 /**
@@ -296,6 +332,7 @@
 {
 	wmi_fwtest_set_param_cmd *cmd;
 	wmi_buf_t buf;
+	QDF_STATUS ret;
 	int len = sizeof(wmi_fwtest_set_param_cmd);
 
 	buf = wmi_buf_alloc(wmi_handle, len);
@@ -309,7 +346,12 @@
 	cmd->param_id = param->arg;
 	cmd->param_value = param->value;
 
-	return wmi_unified_cmd_send(wmi_handle, buf, len, WMI_FWTEST_CMDID);
+	ret =  wmi_unified_cmd_send(wmi_handle, buf, len, WMI_FWTEST_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_FWTEST_CMDID");
+		wmi_buf_free(buf);
+	}
+	return ret;
 }
 
 /**
@@ -324,6 +366,7 @@
 {
 	wmi_vdev_config_ratemask *cmd;
 	wmi_buf_t buf;
+	QDF_STATUS ret;
 	int len = sizeof(wmi_vdev_config_ratemask);
 
 	buf = wmi_buf_alloc(wmi_handle, len);
@@ -338,8 +381,13 @@
 	cmd->mask_higher32 = param->higher32;
 	WMI_LOGD("Setting vdev ratemask vdev id = 0x%X, type = 0x%X, mask_l32 = 0x%X mask_h32 = 0x%X",
 		  param->vdev_id, param->type, param->lower32, param->higher32);
-	return wmi_unified_cmd_send(wmi_handle, buf, len,
+	ret =  wmi_unified_cmd_send(wmi_handle, buf, len,
 			WMI_VDEV_RATEMASK_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_VDEV_RATEMASK_CMDID");
+		wmi_buf_free(buf);
+	}
+	return ret;
 }
 
 /**
@@ -355,6 +403,7 @@
 {
 	wmi_vdev_install_key_cmd *cmd;
 	wmi_buf_t buf;
+	QDF_STATUS ret;
 	/* length depends on ieee key length */
 	int len = sizeof(wmi_vdev_install_key_cmd) + param->key_len;
 	uint8_t	wmi_cipher_type;
@@ -439,8 +488,13 @@
 	WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(cmd->key_data, param->key_data,
 			cmd->key_len);
 
-	return wmi_unified_cmd_send(wmi_handle, buf, len,
+	ret =  wmi_unified_cmd_send(wmi_handle, buf, len,
 			WMI_VDEV_INSTALL_KEY_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_VDEV_INSTALL_KEY_CMDID");
+		wmi_buf_free(buf);
+	}
+	return ret;
 
 }
 
@@ -499,6 +553,7 @@
 {
 	wmi_peer_flush_tids_cmd *cmd;
 	wmi_buf_t buf;
+	QDF_STATUS ret;
 	int len = sizeof(wmi_peer_flush_tids_cmd);
 
 	buf = wmi_buf_alloc(wmi_handle, len);
@@ -510,8 +565,13 @@
 	WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
 	cmd->peer_tid_bitmap = param->peer_tid_bitmap;
 	cmd->vdev_id = param->vdev_id;
-	return wmi_unified_cmd_send(wmi_handle, buf, len,
+	ret =  wmi_unified_cmd_send(wmi_handle, buf, len,
 			WMI_PEER_FLUSH_TIDS_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_PEER_FLUSH_TIDS_CMDID");
+		wmi_buf_free(buf);
+	}
+	return ret;
 }
 
 /**
@@ -529,6 +589,7 @@
 {
 	wmi_peer_delete_cmd *cmd;
 	wmi_buf_t buf;
+	QDF_STATUS ret;
 	int len = sizeof(wmi_peer_delete_cmd);
 
 	buf = wmi_buf_alloc(wmi_handle, len);
@@ -539,8 +600,13 @@
 	cmd = (wmi_peer_delete_cmd *)wmi_buf_data(buf);
 	WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
 	cmd->vdev_id = vdev_id;
-	return wmi_unified_cmd_send(wmi_handle, buf, len,
+	ret =  wmi_unified_cmd_send(wmi_handle, buf, len,
 			WMI_PEER_DELETE_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_PEER_DELETE_CMDID");
+		wmi_buf_free(buf);
+	}
+	return ret;
 }
 
 /**
@@ -613,6 +679,7 @@
 {
 	wmi_peer_set_param_cmd *cmd;
 	wmi_buf_t buf;
+	QDF_STATUS ret;
 	int len = sizeof(wmi_peer_set_param_cmd);
 	uint32_t param_id;
 
@@ -630,8 +697,13 @@
 	cmd->param_id = param_id;
 	cmd->param_value = param->param_value;
 	cmd->vdev_id = param->vdev_id;
-	return wmi_unified_cmd_send(wmi_handle, buf, len,
+	ret =  wmi_unified_cmd_send(wmi_handle, buf, len,
 			WMI_PEER_SET_PARAM_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_PEER_SET_PARAM_CMDID");
+		wmi_buf_free(buf);
+	}
+	return ret;
 }
 
 /**
@@ -648,6 +720,7 @@
 {
 	wmi_vdev_up_cmd *cmd;
 	wmi_buf_t buf;
+	QDF_STATUS ret;
 	int len = sizeof(wmi_vdev_up_cmd);
 
 	buf = wmi_buf_alloc(wmi_handle, len);
@@ -660,7 +733,12 @@
 	cmd->vdev_assoc_id = param->assoc_id;
 	WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid, &cmd->vdev_bssid);
 	WMI_LOGD("%s for vap %d (%pK)", __func__, param->vdev_id, wmi_handle);
-	return wmi_unified_cmd_send(wmi_handle, buf, len, WMI_VDEV_UP_CMDID);
+	ret =  wmi_unified_cmd_send(wmi_handle, buf, len, WMI_VDEV_UP_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_VDEV_UP_CMDID");
+		wmi_buf_free(buf);
+	}
+	return ret;
 }
 
 /**
@@ -749,6 +827,7 @@
 {
 	wmi_peer_create_cmd *cmd;
 	wmi_buf_t buf;
+	QDF_STATUS ret;
 	int len = sizeof(wmi_peer_create_cmd);
 
 	buf = wmi_buf_alloc(wmi_handle, len);
@@ -759,8 +838,13 @@
 	cmd = (wmi_peer_create_cmd *)wmi_buf_data(buf);
 	WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
 	cmd->vdev_id = param->vdev_id;
-	return wmi_unified_cmd_send(wmi_handle, buf, len,
+	ret = wmi_unified_cmd_send(wmi_handle, buf, len,
 			WMI_PEER_CREATE_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_PEER_CREATE_CMDID");
+		wmi_buf_free(buf);
+	}
+	return ret;
 }
 
 /**
@@ -775,6 +859,7 @@
 {
 	wmi_peer_add_wds_entry_cmd *cmd;
 	wmi_buf_t buf;
+	QDF_STATUS ret;
 	int len = sizeof(wmi_peer_add_wds_entry_cmd);
 
 	buf = wmi_buf_alloc(wmi_handle, len);
@@ -786,8 +871,13 @@
 	WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
 	WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
 	cmd->flags = param->flags;
-	return wmi_unified_cmd_send(wmi_handle, buf, len,
+	ret = wmi_unified_cmd_send(wmi_handle, buf, len,
 			WMI_PEER_ADD_WDS_ENTRY_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_PEER_ADD_WDS_ENTRY_CMDID");
+		wmi_buf_free(buf);
+	}
+	return ret;
 }
 
 /**
@@ -802,6 +892,7 @@
 {
 	wmi_peer_remove_wds_entry_cmd *cmd;
 	wmi_buf_t buf;
+	QDF_STATUS ret;
 	int len = sizeof(wmi_peer_remove_wds_entry_cmd);
 
 	buf = wmi_buf_alloc(wmi_handle, len);
@@ -811,8 +902,13 @@
 	}
 	cmd = (wmi_peer_remove_wds_entry_cmd *)wmi_buf_data(buf);
 	WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
-	return wmi_unified_cmd_send(wmi_handle, buf, len,
+	ret = wmi_unified_cmd_send(wmi_handle, buf, len,
 			WMI_PEER_REMOVE_WDS_ENTRY_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_PEER_REMOVE_WDS_ENTRY_CMDID");
+		wmi_buf_free(buf);
+	}
+	return ret;
 }
 
 /**
@@ -827,6 +923,7 @@
 {
 	wmi_peer_add_wds_entry_cmd *cmd;
 	wmi_buf_t buf;
+	QDF_STATUS ret;
 	uint8_t null_macaddr[QDF_MAC_ADDR_SIZE];
 	int len = sizeof(wmi_peer_add_wds_entry_cmd);
 
@@ -841,8 +938,13 @@
 	WMI_CHAR_ARRAY_TO_MAC_ADDR(null_macaddr, &cmd->peer_macaddr);
 	cmd->flags = 0xffffffff;
 
-	return wmi_unified_cmd_send(wmi_handle, buf, len,
+	ret =  wmi_unified_cmd_send(wmi_handle, buf, len,
 			WMI_PEER_ADD_WDS_ENTRY_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_PEER_ADD_WDS_ENTRY_CMDID");
+		wmi_buf_free(buf);
+	}
+	return ret;
 }
 
 /**
@@ -857,6 +959,7 @@
 {
 	wmi_peer_update_wds_entry_cmd *cmd;
 	wmi_buf_t buf;
+	QDF_STATUS ret;
 	int len = sizeof(wmi_peer_update_wds_entry_cmd);
 
 	buf = wmi_buf_alloc(wmi_handle, len);
@@ -874,8 +977,13 @@
 	if (param->peer_macaddr)
 		WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr,
 				&cmd->peer_macaddr);
-	return wmi_unified_cmd_send(wmi_handle, buf, len,
+	ret =  wmi_unified_cmd_send(wmi_handle, buf, len,
 			WMI_PEER_UPDATE_WDS_ENTRY_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_PEER_UPDATE_WDS_ENTRY_CMDID");
+		wmi_buf_free(buf);
+	}
+	return ret;
 }
 
 #ifdef WLAN_SUPPORT_GREEN_AP
@@ -917,6 +1025,10 @@
 				 value,
 				 ret);
 #endif /* OL_GREEN_AP_DEBUG_CONFIG_INTERACTIONS */
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID");
+		wmi_buf_free(buf);
+	}
 	return ret;
 }
 #endif
@@ -1014,6 +1126,10 @@
 
 	msgref++;
 
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_PDEV_UTF_CMDID");
+		wmi_buf_free(buf);
+	}
 	return ret;
 }
 
@@ -1087,6 +1203,9 @@
 
 	msgref++;
 
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		wmi_buf_free(buf);
+	}
 	return ret;
 }
 
@@ -1104,6 +1223,7 @@
 {
 	wmi_pdev_set_param_cmd *cmd;
 	wmi_buf_t buf;
+	QDF_STATUS ret;
 	int len = sizeof(wmi_pdev_set_param_cmd);
 
 	if ((param->param_id < wmi_pdev_param_max) &&
@@ -1119,8 +1239,13 @@
 		cmd = (wmi_pdev_set_param_cmd *)wmi_buf_data(buf);
 		cmd->param_id = wmi_handle->soc->pdev_param[param->param_id];
 		cmd->param_value = param->param_value;
-		return wmi_unified_cmd_send(wmi_handle, buf, len,
+		ret =  wmi_unified_cmd_send(wmi_handle, buf, len,
 			WMI_PDEV_SET_PARAM_CMDID);
+		if (QDF_IS_STATUS_ERROR(ret)) {
+			WMI_LOGE("Failed to send WMI_PDEV_SET_PARAM_CMDID");
+			wmi_buf_free(buf);
+		}
+		return ret;
 	}
 	return QDF_STATUS_E_FAILURE;
 }
@@ -1139,6 +1264,7 @@
 {
 	wmi_pdev_suspend_cmd *cmd;
 	wmi_buf_t wmibuf;
+	QDF_STATUS ret;
 	uint32_t len = sizeof(wmi_pdev_suspend_cmd);
 
 	/*send the command to Target to ignore the
@@ -1160,8 +1286,13 @@
 	 */
 	wmi_flush_endpoint(wmi_handle);
 
-	return wmi_unified_cmd_send(wmi_handle, wmibuf, len,
+	ret =  wmi_unified_cmd_send(wmi_handle, wmibuf, len,
 			WMI_PDEV_SUSPEND_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_PDEV_SUSPEND_CMDID");
+		wmi_buf_free(wmibuf);
+	}
+	return ret;
 }
 
 /**
@@ -1175,12 +1306,17 @@
 				uint8_t mac_id)
 {
 	wmi_buf_t wmibuf;
-
+	QDF_STATUS ret;
 	wmibuf = wmi_buf_alloc(wmi_handle, 0);
 	if (wmibuf == NULL)
 		return QDF_STATUS_E_NOMEM;
-	return wmi_unified_cmd_send(wmi_handle, wmibuf, 0,
+	ret = wmi_unified_cmd_send(wmi_handle, wmibuf, 0,
 			WMI_PDEV_RESUME_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_PDEV_RESUME_CMDID");
+		wmi_buf_free(wmibuf);
+	}
+	return ret;
 }
 
 /**
@@ -1204,6 +1340,9 @@
 	}
 	res = wmi_unified_cmd_send(wmi_handle, buf, 4, WMI_WOW_ENABLE_CMDID);
 	WMI_LOGD("send_wow_enable result: %d", res);
+	if (QDF_IS_STATUS_ERROR(res)) {
+		wmi_buf_free(buf);
+	}
 	return (res == QDF_STATUS_SUCCESS) ?
 		QDF_STATUS_SUCCESS : QDF_STATUS_E_FAILURE;
 }
@@ -1227,6 +1366,9 @@
 	res = wmi_unified_cmd_send(wmi_handle, buf, 4,
 			WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID);
 	WMI_LOGD("ol_wow_wakeup result: %d", res);
+	if (QDF_IS_STATUS_ERROR(res)) {
+		wmi_buf_free(buf);
+	}
 	return (res == QDF_STATUS_SUCCESS) ?
 		QDF_STATUS_SUCCESS : QDF_STATUS_E_FAILURE;
 }
@@ -1256,6 +1398,10 @@
 	cmd->event_bitmap = param->type;
 	res = wmi_unified_cmd_send(wmi_handle, buf, len,
 			WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID);
+	if (QDF_IS_STATUS_ERROR(res)) {
+		WMI_LOGE("Failed to send WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID");
+		wmi_buf_free(buf);
+	}
 	return (res == QDF_STATUS_SUCCESS) ?
 		QDF_STATUS_SUCCESS : QDF_STATUS_E_FAILURE;
 }
@@ -1302,7 +1448,10 @@
 	cmd->pattern_info.bitmap = bitmap_pattern;
 	res = wmi_unified_cmd_send(wmi_handle, buf, len,
 			WMI_WOW_ADD_WAKE_PATTERN_CMDID);
-
+	if (QDF_IS_STATUS_ERROR(res)) {
+		WMI_LOGE("Failed to send WMI_WOW_ADD_WAKE_PATTERN_CMDID");
+		wmi_buf_free(buf);
+	}
 	return (res == QDF_STATUS_SUCCESS) ?
 		QDF_STATUS_SUCCESS : QDF_STATUS_E_FAILURE;
 }
@@ -1333,6 +1482,10 @@
 	cmd->pattern_type = WOW_BITMAP_PATTERN;
 	res = wmi_unified_cmd_send(wmi_handle, buf, len,
 			WMI_WOW_DEL_WAKE_PATTERN_CMDID);
+	if (QDF_IS_STATUS_ERROR(res)) {
+		WMI_LOGE("Failed to send WMI_WOW_DEL_WAKE_PATTERN_CMDID");
+		wmi_buf_free(buf);
+	}
 	return (res == QDF_STATUS_SUCCESS) ?
 		QDF_STATUS_SUCCESS : QDF_STATUS_E_FAILURE;
 }
@@ -1351,6 +1504,7 @@
 {
 	wmi_ap_ps_peer_cmd *cmd;
 	wmi_buf_t buf;
+	QDF_STATUS ret;
 
 	buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
 	if (!buf) {
@@ -1364,8 +1518,13 @@
 	cmd->param = param->param;
 	cmd->value = param->value;
 
-	return wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
+	ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
 			WMI_AP_PS_PEER_PARAM_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_AP_PS_PEER_PARAM_CMDID");
+		wmi_buf_free(buf);
+	}
+	return ret;
 }
 
 /**
@@ -1380,6 +1539,7 @@
 {
 	wmi_sta_powersave_param_cmd *cmd;
 	wmi_buf_t buf;
+	QDF_STATUS ret;
 
 	buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
 	if (!buf) {
@@ -1392,8 +1552,13 @@
 	cmd->param = param->param_id;
 	cmd->value = param->value;
 
-	return wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
+	ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
 			WMI_STA_POWERSAVE_PARAM_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_STA_POWERSAVE_PARAM_CMDID");
+		wmi_buf_free(buf);
+	}
+	return ret;
 }
 
 /**
@@ -1422,6 +1587,10 @@
 
 	ret =  wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
 			WMI_STA_POWERSAVE_MODE_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_STA_POWERSAVE_MODE_CMDID");
+		wmi_buf_free(buf);
+	}
 
 	return ret;
 }
@@ -1438,6 +1607,7 @@
 {
 	WMI_FORCE_FW_HANG_CMD *cmd;
 	wmi_buf_t buf;
+	QDF_STATUS ret;
 	int32_t len = sizeof(WMI_FORCE_FW_HANG_CMD);
 
 	buf = wmi_buf_alloc(wmi_handle, len);
@@ -1449,8 +1619,15 @@
 	cmd->type = 1;
 	/* Should this be param->type ? */
 	cmd->delay_time_ms = param->delay_time_ms;
-	return wmi_unified_cmd_send(wmi_handle, buf, len,
+	ret = wmi_unified_cmd_send(wmi_handle, buf, len,
 			WMI_FORCE_FW_HANG_CMDID);
+
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_FORCE_FW_HANG_CMDID");
+		wmi_buf_free(buf);
+	}
+
+	return ret;
 }
 
 /**
@@ -1491,6 +1668,10 @@
 	status = wmi_unified_cmd_send(wmi_handle, osbuf,
 				   sizeof(WMI_DBGLOG_CFG_CMD),
 				   WMI_DBGLOG_CFG_CMDID);
+	if (QDF_IS_STATUS_ERROR(status)) {
+		WMI_LOGE("Failed to send WMI_DBGLOG_CFG_CMDID");
+		wmi_buf_free(osbuf);
+	}
 
 	return status;
 }
@@ -1507,6 +1688,7 @@
 {
 	wmi_vdev_set_param_cmd *cmd;
 	wmi_buf_t buf;
+	QDF_STATUS ret;
 	int len = sizeof(wmi_vdev_set_param_cmd);
 
 	if ((param->param_id < wmi_vdev_param_max) &&
@@ -1523,8 +1705,13 @@
 		cmd->vdev_id = param->vdev_id;
 		cmd->param_id = wmi_handle->soc->vdev_param[param->param_id];
 		cmd->param_value = param->param_value;
-		return wmi_unified_cmd_send(wmi_handle, buf, len,
+		ret = wmi_unified_cmd_send(wmi_handle, buf, len,
 				WMI_VDEV_SET_PARAM_CMDID);
+		if (QDF_IS_STATUS_ERROR(ret)) {
+			WMI_LOGE("Failed to send WMI_VDEV_SET_PARAM_CMDID");
+			wmi_buf_free(buf);
+		}
+		return ret;
 	}
 	return QDF_STATUS_E_FAILURE;
 }
@@ -1541,6 +1728,7 @@
 {
 	wmi_vdev_sifs_trigger_time_cmd *cmd;
 	wmi_buf_t buf;
+	QDF_STATUS ret;
 	int len = sizeof(wmi_vdev_sifs_trigger_time_cmd);
 
 	buf = wmi_buf_alloc(wmi_handle, len);
@@ -1552,8 +1740,14 @@
 	cmd->vdev_id = param->vdev_id;
 	cmd->sifs_trigger_time = param->param_value;
 
-	return wmi_unified_cmd_send(wmi_handle, buf, len,
+	ret = wmi_unified_cmd_send(wmi_handle, buf, len,
 				    WMI_VDEV_SIFS_TRIGGER_TIME_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_VDEV_SIFS_TRIGGER_TIME_CMDID");
+		wmi_buf_free(buf);
+	}
+
+	return ret;
 }
 
 /**
@@ -1612,6 +1806,8 @@
 
 	if (wmi_unified_cmd_send(wmi_handle, buf, len,
 		WMI_REQUEST_STATS_CMDID)) {
+		WMI_LOGE("Failed to send WMI_REQUEST_STATS_CMDID");
+		wmi_buf_free(buf);
 		return QDF_STATUS_E_INVAL;
 	}
 
@@ -1644,6 +1840,8 @@
 
 	if (wmi_unified_cmd_send(wmi_handle, buf, len,
 				WMI_PDEV_BSS_CHAN_INFO_REQUEST_CMDID)) {
+		WMI_LOGE("Failed to send WMI_PDEV_BSS_CHAN_INFO_REQUEST_CMDID");
+		wmi_buf_free(buf);
 		return QDF_STATUS_E_INVAL;
 	}
 
@@ -1675,6 +1873,8 @@
 	cmd->evlist = PKTLOG_EVENT;
 	if (wmi_unified_cmd_send(wmi_handle, buf, len,
 		    WMI_PDEV_PKTLOG_ENABLE_CMDID)) {
+		WMI_LOGE("Failed to send WMI_PDEV_PKTLOG_ENABLE_CMDID");
+		wmi_buf_free(buf);
 		return QDF_STATUS_E_FAILURE;
 	}
 	return QDF_STATUS_SUCCESS;
@@ -1700,6 +1900,8 @@
 	}
 	if (wmi_unified_cmd_send(wmi_handle, buf, len,
 		    WMI_PDEV_PKTLOG_DISABLE_CMDID)) {
+		WMI_LOGE("Failed to send WMI_PDEV_PKTLOG_DISABLE_CMDID");
+		wmi_buf_free(buf);
 		return QDF_STATUS_E_FAILURE;
 	}
 	return QDF_STATUS_SUCCESS;
@@ -1718,6 +1920,7 @@
 	if (param->is_high_latency) {
 		wmi_bcn_tx_cmd *cmd;
 		wmi_buf_t wmi_buf;
+		QDF_STATUS ret;
 		int bcn_len = qdf_nbuf_len(param->wbuf);
 		int len = sizeof(wmi_bcn_tx_hdr) + bcn_len;
 
@@ -1761,11 +1964,16 @@
 #ifdef DEBUG_BEACON
 		WMI_LOGD("%s frm length %d", __func__, bcn_len);
 #endif
-		wmi_unified_cmd_send(wmi_handle, wmi_buf,
+		ret = wmi_unified_cmd_send(wmi_handle, wmi_buf,
 			roundup(len, sizeof(u_int32_t)), WMI_BCN_TX_CMDID);
+		if (QDF_IS_STATUS_ERROR(ret)) {
+			WMI_LOGE("Failed to send WMI_BCN_TX_CMDID");
+			wmi_buf_free(wmi_buf);
+		}
 	} else {
 		wmi_bcn_send_from_host_cmd_t  *cmd;
 		wmi_buf_t wmi_buf;
+		QDF_STATUS ret;
 		int bcn_len = qdf_nbuf_len(param->wbuf);
 		int len = sizeof(wmi_bcn_send_from_host_cmd_t);
 		uint32_t   dtim_flag = 0;
@@ -1797,8 +2005,12 @@
 		cmd->frag_ptr = qdf_nbuf_get_frag_paddr(param->wbuf, 0);
 		cmd->virt_addr = (uintptr_t)param->wbuf;
 		cmd->bcn_antenna = param->bcn_txant;
-		wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
+		ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
 				WMI_PDEV_SEND_BCN_CMDID);
+		if (QDF_IS_STATUS_ERROR(ret)) {
+			WMI_LOGE("Failed to send WMI_PDEV_SEND_BCN_CMDID");
+			wmi_buf_free(wmi_buf);
+		}
 	}
 	return QDF_STATUS_SUCCESS;
 }
@@ -1868,6 +2080,7 @@
 {
 	wmi_peer_assoc_complete_cmd *cmd;
 	int len = sizeof(wmi_peer_assoc_complete_cmd);
+	QDF_STATUS ret;
 #ifdef BIG_ENDIAN_HOST
 	int i;
 #endif
@@ -2033,7 +2246,14 @@
 	/*Send bandwidth-NSS mapping to FW*/
 	cmd->peer_bw_rxnss_override |= param->peer_bw_rxnss_override;
 
-	return wmi_unified_cmd_send(wmi_handle, buf, len, WMI_PEER_ASSOC_CMDID);
+	ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_PEER_ASSOC_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_PEER_ASSOC_CMDID");
+		wmi_buf_free(buf);
+	}
+
+	return ret;
+
 }
 
 /**
@@ -2048,6 +2268,7 @@
 {
 	wmi_start_scan_cmd *cmd;
 	wmi_buf_t buf;
+	QDF_STATUS ret;
 	wmi_chan_list *chan_list;
 	wmi_bssid_list *bssid_list;
 	wmi_ssid_list *ssid_list;
@@ -2240,7 +2461,14 @@
 				param->extraie.ptr, param->extraie.len);
 	}
 	WMI_LOGD("Sending SCAN START cmd");
-	return wmi_unified_cmd_send(wmi_handle, buf, len, WMI_START_SCAN_CMDID);
+	ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_START_SCAN_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_START_SCAN_CMDID");
+		wmi_buf_free(buf);
+	}
+
+	return ret;
+
 }
 
 /**
@@ -2255,6 +2483,7 @@
 {
 	wmi_stop_scan_cmd *cmd = NULL;
 	wmi_buf_t buf;
+	QDF_STATUS ret;
 	u_int32_t len = sizeof(wmi_stop_scan_cmd);
 
 	buf = wmi_buf_alloc(wmi_handle, len);
@@ -2286,7 +2515,11 @@
 		cmd->req_type = WMI_SCAN_STOP_ONE;
 	}
 
-	wmi_unified_cmd_send(wmi_handle, buf, len, WMI_STOP_SCAN_CMDID);
+	ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_STOP_SCAN_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_STOP_SCAN_CMDID");
+		wmi_buf_free(buf);
+	}
 
 	return QDF_STATUS_SUCCESS;
 }
@@ -2303,6 +2536,7 @@
 {
 	uint32_t i;
 	wmi_buf_t buf;
+	QDF_STATUS ret;
 	wmi_scan_chan_list_cmd *cmd;
 	int len = sizeof(wmi_scan_chan_list_cmd);
 
@@ -2360,7 +2594,12 @@
 				param->ch_param[i].reg_class_id);
 	}
 
-	wmi_unified_cmd_send(wmi_handle, buf, len, WMI_SCAN_CHAN_LIST_CMDID);
+	ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_SCAN_CHAN_LIST_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
+		wmi_buf_free(buf);
+	}
+
 	return QDF_STATUS_SUCCESS;
 }
 
@@ -2400,6 +2639,11 @@
 
 	error = wmi_unified_cmd_send(wmi_handle, buf, len,
 			WMI_TT_SET_CONF_CMDID);
+	if (QDF_IS_STATUS_ERROR(error)) {
+		WMI_LOGE("Failed to send WMI_TT_SET_CONF_CMDID");
+		wmi_buf_free(buf);
+	}
+
 	return error;
 }
 
@@ -2427,6 +2671,7 @@
 	if (wmi_unified_cmd_send(wmi_handle, buf, 32,
 	  WMI_PDEV_DFS_ENABLE_CMDID) != QDF_STATUS_SUCCESS) {
 		WMI_LOGE("%s: send failed", __func__);
+		wmi_buf_free(buf);
 		return QDF_STATUS_E_FAILURE;
 	}
 	return QDF_STATUS_SUCCESS;
@@ -2456,6 +2701,7 @@
 	if (wmi_unified_cmd_send(wmi_handle, buf, 32,
 	  WMI_PDEV_DFS_DISABLE_CMDID) != QDF_STATUS_SUCCESS) {
 		WMI_LOGE("%s: send failed", __func__);
+		wmi_buf_free(buf);
 		return QDF_STATUS_E_FAILURE;
 	}
 	return QDF_STATUS_SUCCESS;
@@ -2732,6 +2978,7 @@
 		WMI_LOGE(" %s :WMI Failed", __func__);
 		WMI_LOGE("%s: Sent WMI_PEER_SMART_ANT_SET_NODE_CONFIG_OPS_CMDID, cmd_id: 0x%x\n Node: %s cmdstatus=%d",
 			  __func__, param->cmd_id, ether_sprintf(macaddr), ret);
+		wmi_buf_free(buf);
 	}
 	return ret;
 }
@@ -2766,8 +3013,10 @@
 		cmd->evlist = types;
 		/*enabling the pktlog for smart antenna tx feedback*/
 		if (wmi_unified_cmd_send(wmi_handle, buf, len,
-					WMI_PDEV_PKTLOG_ENABLE_CMDID))
+					WMI_PDEV_PKTLOG_ENABLE_CMDID)) {
+			wmi_buf_free(buf);
 			return QDF_STATUS_E_FAILURE;
+		}
 		return QDF_STATUS_SUCCESS;
 	} else if (param->enable == 0) {
 		buf = wmi_buf_alloc(wmi_handle, 0);
@@ -2776,8 +3025,10 @@
 			return QDF_STATUS_E_FAILURE;
 		}
 		if (!wmi_unified_cmd_send(wmi_handle, buf, len,
-					WMI_PDEV_PKTLOG_DISABLE_CMDID))
+					WMI_PDEV_PKTLOG_DISABLE_CMDID)) {
+			wmi_buf_free(buf);
 			return QDF_STATUS_E_FAILURE;
+		}
 		return QDF_STATUS_SUCCESS;
 	} else
 		return QDF_STATUS_E_FAILURE;
@@ -2876,6 +3127,11 @@
 		  param->chn_mask);
 	WMI_LOGD("%s: Status: %d", __func__, ret);
 
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID");
+		wmi_buf_free(buf);
+	}
+
 	return ret;
 }
 
@@ -3028,10 +3284,13 @@
 				   len,
 				   WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID);
 
-	WMI_LOGD
-		("%s: Sent WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID\n", __func__);
-
-	WMI_LOGD("%s: Status: %d", __func__, ret);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID");
+		wmi_buf_free(buf);
+	} else {
+		WMI_LOGD("%s: Sent WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID\n", __func__);
+		WMI_LOGD("%s: Status: %d", __func__, ret);
+	}
 
 	return ret;
 }
@@ -3049,6 +3308,7 @@
 {
 	wmi_pdev_set_regdomain_cmd *cmd;
 	wmi_buf_t buf;
+	QDF_STATUS ret;
 
 	int len = sizeof(wmi_pdev_set_regdomain_cmd);
 
@@ -3067,8 +3327,15 @@
 	cmd->conformance_test_limit_5G = param->ctl_5G;
 	cmd->dfs_domain = param->dfsDomain;
 
-	return wmi_unified_cmd_send(wmi_handle, buf, len,
+	ret =  wmi_unified_cmd_send(wmi_handle, buf, len,
 				WMI_PDEV_SET_REGDOMAIN_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_PDEV_SET_REGDOMAIN_CMDID");
+		wmi_buf_free(buf);
+	}
+
+	return ret;
+
 }
 
 /**
@@ -3084,6 +3351,7 @@
 {
 	wmi_buf_t buf;
 	wmi_pdev_set_quiet_cmd *quiet_cmd;
+	QDF_STATUS ret;
 	int len = sizeof(wmi_pdev_set_quiet_cmd);
 
 	buf = wmi_buf_alloc(wmi_handle, len);
@@ -3096,9 +3364,14 @@
 	quiet_cmd->period = (param->period)*(param->intval);
 	quiet_cmd->duration = param->duration;
 	quiet_cmd->next_start = param->offset;
-	wmi_unified_cmd_send(wmi_handle, buf, len,
+	ret = wmi_unified_cmd_send(wmi_handle, buf, len,
 			WMI_PDEV_SET_QUIET_MODE_CMDID);
-	return QDF_STATUS_SUCCESS;
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_PDEV_SET_QUIET_MODE_CMDID");
+		wmi_buf_free(buf);
+	}
+
+	return ret;
 }
 
 /**
@@ -3137,6 +3410,11 @@
 	}
 	res = wmi_unified_cmd_send(wmi_handle, buf, len,
 			WMI_ADD_BCN_FILTER_CMDID);
+	if (QDF_IS_STATUS_ERROR(res)) {
+		WMI_LOGE("Failed to send WMI_ADD_BCN_FILTER_CMDID");
+		wmi_buf_free(buf);
+	}
+
 	return (res == QDF_STATUS_SUCCESS) ?
 		QDF_STATUS_SUCCESS : QDF_STATUS_E_FAILURE;
 }
@@ -3167,6 +3445,11 @@
 	cmd->vdev_id = param->vdev_id;
 	res = wmi_unified_cmd_send(wmi_handle, buf, len,
 			WMI_RMV_BCN_FILTER_CMDID);
+	if (QDF_IS_STATUS_ERROR(res)) {
+		WMI_LOGE("Failed to send WMI_RMV_BCN_FILTER_CMDID");
+		wmi_buf_free(buf);
+	}
+
 	return (res == QDF_STATUS_SUCCESS) ?
 		QDF_STATUS_SUCCESS : QDF_STATUS_E_FAILURE;
 }
@@ -3183,6 +3466,7 @@
 {
 	wmi_mgmt_tx_cmd *cmd;
 	wmi_buf_t wmi_buf;
+	QDF_STATUS ret;
 	int len = sizeof(wmi_mgmt_tx_hdr) + param->frm_len;
 
 	wmi_buf = wmi_buf_alloc(wmi_handle, roundup(len, sizeof(u_int32_t)));
@@ -3219,8 +3503,13 @@
 #endif
 
 	/* Send the management frame buffer to the target */
-	wmi_unified_cmd_send(wmi_handle, wmi_buf, roundup(len,
+	ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, roundup(len,
 		    sizeof(u_int32_t)), WMI_MGMT_TX_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_MGMT_TX_CMDID");
+		wmi_buf_free(wmi_buf);
+	}
+
 	return QDF_STATUS_SUCCESS;
 }
 
@@ -3239,6 +3528,7 @@
 {
 	wmi_addba_clear_resp_cmd *cmd;
 	wmi_buf_t buf;
+	QDF_STATUS ret;
 	int len = sizeof(wmi_addba_clear_resp_cmd);
 
 	buf = wmi_buf_alloc(wmi_handle, len);
@@ -3251,7 +3541,12 @@
 	WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
 
 	/* Send the management frame buffer to the target */
-	wmi_unified_cmd_send(wmi_handle, buf, len, WMI_ADDBA_CLEAR_RESP_CMDID);
+	ret =  wmi_unified_cmd_send(wmi_handle, buf, len, WMI_ADDBA_CLEAR_RESP_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_ADDBA_CLEAR_RESP_CMDID");
+		wmi_buf_free(buf);
+	}
+
 	return QDF_STATUS_SUCCESS;
 }
 
@@ -3269,6 +3564,7 @@
 {
 	wmi_addba_send_cmd *cmd;
 	wmi_buf_t buf;
+	QDF_STATUS ret;
 	int len = sizeof(wmi_addba_send_cmd);
 
 	buf = wmi_buf_alloc(wmi_handle, len);
@@ -3283,7 +3579,12 @@
 	cmd->buffersize = param->buffersize;
 
 	/* Send the management frame buffer to the target */
-	wmi_unified_cmd_send(wmi_handle, buf, len, WMI_ADDBA_SEND_CMDID);
+	ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_ADDBA_SEND_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_ADDBA_SEND_CMDID");
+		wmi_buf_free(buf);
+	}
+
 	return QDF_STATUS_SUCCESS;
 }
 
@@ -3301,6 +3602,7 @@
 {
 	wmi_delba_send_cmd *cmd;
 	wmi_buf_t buf;
+	QDF_STATUS ret;
 	int len = sizeof(wmi_delba_send_cmd);
 
 	buf = wmi_buf_alloc(wmi_handle, len);
@@ -3317,7 +3619,12 @@
 	cmd->reasoncode = param->reasoncode;
 
 	/* send the management frame buffer to the target */
-	wmi_unified_cmd_send(wmi_handle, buf, len, WMI_DELBA_SEND_CMDID);
+	ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_DELBA_SEND_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_DELBA_SEND_CMDID");
+		wmi_buf_free(buf);
+	}
+
 	return QDF_STATUS_SUCCESS;
 }
 
@@ -3335,6 +3642,7 @@
 {
 	wmi_addba_setresponse_cmd *cmd;
 	wmi_buf_t buf;
+	QDF_STATUS ret;
 	int len = sizeof(wmi_addba_setresponse_cmd);
 
 	buf = wmi_buf_alloc(wmi_handle, len);
@@ -3350,7 +3658,13 @@
 	cmd->statuscode = param->statuscode;
 
 	/* send the management frame buffer to the target */
-	wmi_unified_cmd_send(wmi_handle, buf, len, WMI_ADDBA_SET_RESP_CMDID);
+	ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_ADDBA_SET_RESP_CMDID);
+
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_ADDBA_SET_RESP_CMDID");
+		wmi_buf_free(buf);
+	}
+
 	return QDF_STATUS_SUCCESS;
 }
 
@@ -3368,6 +3682,7 @@
 {
 	wmi_send_singleamsdu_cmd *cmd;
 	wmi_buf_t buf;
+	QDF_STATUS ret;
 	int len = sizeof(wmi_send_singleamsdu_cmd);
 
 	buf = wmi_buf_alloc(wmi_handle, len);
@@ -3382,7 +3697,12 @@
 	cmd->tid = param->tidno;
 
 	/* send the management frame buffer to the target */
-	wmi_unified_cmd_send(wmi_handle, buf, len, WMI_SEND_SINGLEAMSDU_CMDID);
+	ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_SEND_SINGLEAMSDU_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_SEND_SINGLEAMSDU_CMDID");
+		wmi_buf_free(buf);
+	}
+
 	return QDF_STATUS_SUCCESS;
 }
 
@@ -3416,6 +3736,11 @@
 
 	ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
 			WMI_QBOOST_CFG_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_QBOOST_CFG_CMDID");
+		wmi_buf_free(buf);
+	}
+
 	return ret;
 }
 
@@ -3431,6 +3756,7 @@
 {
 	wmi_mu_start_cmd *cmd;
 	wmi_buf_t buf;
+	QDF_STATUS ret;
 
 	buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_mu_start_cmd));
 	if (!buf) {
@@ -3447,9 +3773,16 @@
 	cmd->rssi_thr_sc = param->rssi_thr_sc;
 	cmd->plmn_id = param->plmn_id;
 	cmd->alpha_num_bssid = param->alpha_num_bssid;
-	return wmi_unified_cmd_send(wmi_handle, buf,
+	ret = wmi_unified_cmd_send(wmi_handle, buf,
 				sizeof(wmi_mu_start_cmd),
 				WMI_MU_CAL_START_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_MU_CAL_START_CMDID");
+		wmi_buf_free(buf);
+	}
+
+	return ret;
+
 }
 
 /**
@@ -3464,6 +3797,7 @@
 {
 	wmi_set_lteu_config *cmd;
 	wmi_buf_t buf;
+	QDF_STATUS ret;
 	int i;
 
 	buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_set_lteu_config));
@@ -3484,9 +3818,16 @@
 	cmd->use_actual_nf = param->use_actual_nf;
 	cmd->wifi_tx_power = param->wifi_tx_power;
 	cmd->allow_err_packets = param->allow_err_packets;
-	return wmi_unified_cmd_send(wmi_handle, buf,
+	ret = wmi_unified_cmd_send(wmi_handle, buf,
 				sizeof(wmi_set_lteu_config),
 				WMI_SET_LTEU_CONFIG_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_SET_LTEU_CONFIG_CMDID");
+		wmi_buf_free(buf);
+	}
+
+	return ret;
+
 }
 
 /**
@@ -3502,6 +3843,7 @@
 {
 	wmi_pdev_get_tpc_config_cmd *cmd;
 	wmi_buf_t buf;
+	QDF_STATUS ret;
 	int32_t len = sizeof(wmi_pdev_get_tpc_config_cmd);
 
 	buf = wmi_buf_alloc(wmi_handle, len);
@@ -3511,8 +3853,14 @@
 	}
 	cmd = (wmi_pdev_get_tpc_config_cmd *)wmi_buf_data(buf);
 	cmd->param = param;
-	return wmi_unified_cmd_send(wmi_handle, buf, len,
+	ret = wmi_unified_cmd_send(wmi_handle, buf, len,
 			WMI_PDEV_GET_TPC_CONFIG_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_PDEV_GET_TPC_CONFIG_CMDID");
+		wmi_buf_free(buf);
+	}
+
+	return ret;
 }
 
 /**
@@ -3597,6 +3945,11 @@
 	WMI_LOGD("wmi_unified_pdev_set_atf peer_num=%d", cmd->num_peers);
 	retval = wmi_unified_cmd_send(wmi_handle, buf, len,
 				      WMI_PEER_ATF_REQUEST_CMDID);
+	if (QDF_IS_STATUS_ERROR(retval)) {
+		WMI_LOGE("Failed to send WMI_PEER_ATF_REQUEST_CMDID");
+		wmi_buf_free(buf);
+	}
+
 	return retval;
 }
 
@@ -3639,6 +3992,10 @@
 	}
 	retval = wmi_unified_cmd_send(wmi_handle, buf, len,
 				      WMI_PEER_ATF_EXT_REQUEST_CMDID);
+	if (QDF_IS_STATUS_ERROR(retval)) {
+		WMI_LOGE("Failed to send WMI_PEER_ATF_EXT_REQUEST_CMDID");
+		wmi_buf_free(buf);
+	}
 
 	return retval;
 }
@@ -3679,6 +4036,10 @@
 	}
 	retval = wmi_unified_cmd_send(wmi_handle, buf, len,
 				      WMI_ATF_SSID_GROUPING_REQUEST_CMDID);
+	if (QDF_IS_STATUS_ERROR(retval)) {
+		WMI_LOGE("Failed to send WMI_ATF_SSID_GROUPING_REQUEST_CMDID");
+		wmi_buf_free(buf);
+	}
 
 	return retval;
 }
@@ -3697,6 +4058,7 @@
 	struct wmi_atf_group_wmm_ac_info *group_info;
 	wmi_atf_grp_wmm_ac_cfg_request *cmd;
 	wmi_buf_t buf;
+	QDF_STATUS ret;
 	int len = sizeof(wmi_atf_grp_wmm_ac_cfg_request);
 	int i;
 
@@ -3715,8 +4077,14 @@
 			     sizeof(struct wmi_atf_group_wmm_ac_info));
 	}
 
-	return wmi_unified_cmd_send(wmi_handle, buf, len,
+	ret = wmi_unified_cmd_send(wmi_handle, buf, len,
 				    WMI_ATF_GROUP_WMM_AC_CONFIG_REQUEST_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_ATF_GROUP_WMM_AC_CONFIG_REQUEST_CMDID");
+		wmi_buf_free(buf);
+	}
+
+	return ret;
 }
 
 /**
@@ -3788,6 +4156,7 @@
 {
 	wmi_buf_t buf;
 	uint16_t len;
+	QDF_STATUS ret;
 	wmi_wlan_profile_enable_profile_id_cmd *cmd;
 
 	len = sizeof(wmi_wlan_profile_enable_profile_id_cmd);
@@ -3799,8 +4168,14 @@
 	cmd = (wmi_wlan_profile_enable_profile_id_cmd *)wmi_buf_data(buf);
 	cmd->profile_id = param->profile_id;
 	cmd->enable = param->enable;
-	return wmi_unified_cmd_send(wmi_handle, buf, len,
+	ret =  wmi_unified_cmd_send(wmi_handle, buf, len,
 		WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID");
+		wmi_buf_free(buf);
+	}
+
+	return ret;
 }
 
 /**
@@ -3817,6 +4192,7 @@
 {
 	wmi_buf_t buf;
 	uint16_t len;
+	QDF_STATUS ret;
 	wmi_wlan_profile_trigger_cmd *cmd;
 
 	len = sizeof(wmi_wlan_profile_trigger_cmd);
@@ -3827,8 +4203,14 @@
 	}
 	cmd = (wmi_wlan_profile_trigger_cmd *)wmi_buf_data(buf);
 	cmd->enable = param->enable;
-	return wmi_unified_cmd_send(wmi_handle, buf, len,
+	ret = wmi_unified_cmd_send(wmi_handle, buf, len,
 		WMI_WLAN_PROFILE_TRIGGER_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_WLAN_PROFILE_TRIGGER_CMDID");
+		wmi_buf_free(buf);
+	}
+
+	return ret;
 }
 
 #ifdef BIG_ENDIAN_HOST
@@ -3859,6 +4241,7 @@
 {
 	wmi_pdev_set_ht_ie_cmd *cmd;
 	wmi_buf_t buf;
+	QDF_STATUS ret;
 	/* adjust length to be next multiple of four */
 	int len = (param->ie_len + (sizeof(uint32_t) - 1)) &
 	    (~(sizeof(uint32_t) - 1));
@@ -3878,8 +4261,14 @@
 	WMI_HOST_SWAPME(cmd->ie_data, len-(offsetof(wmi_pdev_set_ht_ie_cmd,
 			ie_data)));
 #endif
-	return wmi_unified_cmd_send(wmi_handle, buf, len,
+	ret =  wmi_unified_cmd_send(wmi_handle, buf, len,
 		WMI_PDEV_SET_HT_CAP_IE_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_PDEV_SET_HT_CAP_IE_CMDID");
+		wmi_buf_free(buf);
+	}
+
+	return ret;
 }
 
 /**
@@ -3895,6 +4284,7 @@
 {
 	wmi_pdev_set_vht_ie_cmd *cmd;
 	wmi_buf_t buf;
+	QDF_STATUS ret;
 	/* adjust length to be next multiple of four */
 	int len = (param->ie_len + (sizeof(u_int32_t) - 1)) &
 	    (~(sizeof(u_int32_t) - 1));
@@ -3914,8 +4304,14 @@
 	WMI_HOST_SWAPME(cmd->ie_data, len-(offsetof(wmi_pdev_set_vht_ie_cmd,
 			ie_data)));
 #endif
-	return wmi_unified_cmd_send(wmi_handle, buf, len,
+	ret =  wmi_unified_cmd_send(wmi_handle, buf, len,
 		WMI_PDEV_SET_VHT_CAP_IE_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_PDEV_SET_VHT_CAP_IE_CMDID");
+		wmi_buf_free(buf);
+	}
+
+	return ret;
 }
 
 /**
@@ -3932,6 +4328,7 @@
 	wmi_buf_t buf;
 	wmi_pdev_set_wmm_params_cmd *cmd;
 	wmi_wmm_params *wmi_param = 0;
+	QDF_STATUS ret;
 	int ac;
 	int len = sizeof(wmi_pdev_set_wmm_params_cmd);
 	struct wmi_host_wmeParams *wmep;
@@ -3971,8 +4368,13 @@
 
 	}
 
-	wmi_unified_cmd_send(wmi_handle, buf, len,
+	ret = wmi_unified_cmd_send(wmi_handle, buf, len,
 		WMI_PDEV_SET_WMM_PARAMS_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_PDEV_SET_WMM_PARAMS_CMDID");
+		wmi_buf_free(buf);
+	}
+
 	return QDF_STATUS_SUCCESS;
 }
 
@@ -4003,6 +4405,8 @@
 
 	if (wmi_unified_cmd_send(wmi_handle, buf, len,
 		WMI_PDEV_SET_ANTENNA_SWITCH_TABLE_CMDID)) {
+		WMI_LOGE("Failed to send WMI_PDEV_SET_ANTENNA_SWITCH_TABLE_CMDID");
+		wmi_buf_free(buf);
 		return QDF_STATUS_E_FAILURE;
 	}
 
@@ -4045,6 +4449,8 @@
 
 	if (wmi_unified_cmd_send(wmi_handle, buf, len,
 		WMI_PDEV_RATEPWR_TABLE_CMDID)) {
+		WMI_LOGE("Failed to send WMI_PDEV_RATEPWR_TABLE_CMDID");
+		wmi_buf_free(buf);
 		return QDF_STATUS_E_FAILURE;
 	}
 
@@ -4079,6 +4485,8 @@
 
 	if (wmi_unified_cmd_send(wmi_handle, buf, len,
 		WMI_PDEV_RATEPWR_TABLE_CMDID)) {
+		WMI_LOGE("Failed to send WMI_PDEV_RATEPWR_TABLE__CMDID");
+		wmi_buf_free(buf);
 		return QDF_STATUS_E_FAILURE;
 	}
 
@@ -4181,6 +4589,7 @@
 	if (wmi_unified_cmd_send(wmi_handle, buf, len,
 			WMI_PDEV_SET_CTL_TABLE_CMDID)) {
 		WMI_LOGE("%s:Failed to send command", __func__);
+		wmi_buf_free(buf);
 		return QDF_STATUS_E_FAILURE;
 	}
 
@@ -4231,6 +4640,8 @@
 
 	if (wmi_unified_cmd_send(wmi_handle, buf, len,
 		WMI_PDEV_SET_MIMOGAIN_TABLE_CMDID)) {
+		WMI_LOGE("Failed to send WMI_PDEV_SET_MIMOGAIN_TABLE_CMDID");
+		wmi_buf_free(buf);
 		return QDF_STATUS_E_FAILURE;
 	}
 
@@ -4253,6 +4664,7 @@
 #define RC_VHT_RATES			2
 	uint16_t len;
 	wmi_buf_t buf;
+	QDF_STATUS ret;
 	wmi_pdev_ratepwr_chainmsk_tbl_cmd *cmd;
 
 	if (!param->ratepwr_chain_tbl)
@@ -4276,8 +4688,13 @@
 				param->num_rate*sizeof(u_int32_t));
 	}
 
-	wmi_unified_cmd_send(wmi_handle, buf, len,
+	ret = wmi_unified_cmd_send(wmi_handle, buf, len,
 				WMI_PDEV_RATEPWR_CHAINMSK_TABLE_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_PDEV_RATEPWR_CHAINMSK_TABLE_CMDID");
+		wmi_buf_free(buf);
+	}
+
 	return QDF_STATUS_SUCCESS;
 }
 
@@ -4307,6 +4724,8 @@
 
 	if (wmi_unified_cmd_send(wmi_handle, buf, len,
 		WMI_PDEV_SET_BASE_MACADDR_CMDID)) {
+		WMI_LOGE("Failed to send WMI_PDEV_SET_BASE_MACADDR_CMDID");
+		wmi_buf_free(buf);
 		return QDF_STATUS_E_FAILURE;
 	}
 
@@ -4391,6 +4810,7 @@
 {
 	wmi_pdev_set_param_cmd *cmd;
 	wmi_buf_t buf;
+	QDF_STATUS ret;
 	uint32_t param_value = 0;
 	int len = sizeof(wmi_pdev_set_param_cmd);
 
@@ -4406,7 +4826,12 @@
 	param_value |= (param->aggrsize_scaling << 8);
 	cmd->param_value = param_value;
 
-	wmi_unified_cmd_send(wmi_handle, buf, len, WMI_PDEV_SET_PARAM_CMDID);
+	ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_PDEV_SET_PARAM_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_PDEV_SET_PARAM_CMDID");
+		wmi_buf_free(buf);
+	}
+
 	return QDF_STATUS_SUCCESS;
 }
 
@@ -4422,6 +4847,7 @@
 				struct vap_dscp_tid_map_params *param)
 {
 	wmi_buf_t buf;
+	QDF_STATUS ret;
 	wmi_vdev_set_dscp_tid_map_cmd *cmd_vdev;
 	int len_vdev = sizeof(wmi_vdev_set_dscp_tid_map_cmd);
 
@@ -4438,8 +4864,14 @@
 	cmd_vdev->vdev_id = param->vdev_id;
 
 	WMI_LOGD("Setting dscp for vap id: %d", cmd_vdev->vdev_id);
-	return wmi_unified_cmd_send(wmi_handle, buf, len_vdev,
+	ret = wmi_unified_cmd_send(wmi_handle, buf, len_vdev,
 		WMI_VDEV_SET_DSCP_TID_MAP_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_VDEV_SET_DSCP_TID_MAP_CMDID");
+		wmi_buf_free(buf);
+	}
+
+		return ret;
 }
 
 /**
@@ -4455,6 +4887,7 @@
 {
 	wmi_pdev_reserve_ast_entry_cmd *cmd;
 	wmi_buf_t buf;
+	QDF_STATUS ret;
 	int len = sizeof(wmi_pdev_reserve_ast_entry_cmd);
 
 	buf = wmi_buf_alloc(wmi_handle, len);
@@ -4470,8 +4903,15 @@
 	WMI_LOGD("%s macaddr=%s key_id=%d mcast=%d", __func__,
 		  ether_sprintf(param->macaddr), cmd->key_id, cmd->mcast);
 
-	return wmi_unified_cmd_send(wmi_handle, buf, len,
+	ret = wmi_unified_cmd_send(wmi_handle, buf, len,
 		WMI_PDEV_RESERVE_AST_ENTRY_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_PDEV_RESERVE_AST_ENTRY_CMDID");
+		wmi_buf_free(buf);
+	}
+
+	return ret;
+
 }
 
 /**
@@ -4622,6 +5062,9 @@
 
 		retval = wmi_unified_cmd_send(wmi_handle, buf, len,
 			WMI_PDEV_FIPS_CMDID);
+		if (QDF_IS_STATUS_ERROR(retval)) {
+			wmi_buf_free(buf);
+		}
 		WMI_LOGD("%s return value %d", __func__, retval);
 	} else {
 		WMI_LOGE("\n%s:%d Key or Data is NULL", __func__, __LINE__);
@@ -4644,6 +5087,7 @@
 {
 	wmi_set_channel_cmd *cmd;
 	wmi_buf_t buf;
+	QDF_STATUS ret;
 	int len = sizeof(wmi_set_channel_cmd);
 
 	buf = wmi_buf_alloc(wmi_handle, len);
@@ -4693,8 +5137,14 @@
 			cmd->chan.band_center_freq1);
 	}
 
-	return wmi_unified_cmd_send(wmi_handle, buf, len,
+	ret =  wmi_unified_cmd_send(wmi_handle, buf, len,
 					WMI_PDEV_SET_CHANNEL_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_PDEV_SET_CHANNEL_CMDID");
+		wmi_buf_free(buf);
+	}
+
+	return ret;
 }
 
 /**
@@ -4710,6 +5160,7 @@
 {
 	wmi_peer_mcast_group_cmd *cmd;
 	wmi_buf_t buf;
+	QDF_STATUS ret;
 	int len;
 	int offset = 0;
 	static char dummymask[4] = { 0xFF, 0xFF, 0xFF, 0xFF};
@@ -4789,8 +5240,12 @@
 		(u_int32_t *)&cmd->mcast_ip_addr,
 		(sizeof(cmd->mcast_ip_addr)) / sizeof(u_int32_t));
 #endif  Little Endian */
-	wmi_unified_cmd_send(
+	ret = wmi_unified_cmd_send(
 			wmi_handle, buf, len, WMI_PEER_MCAST_GROUP_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_PEER_MCAST_GROUP_CMDID");
+		wmi_buf_free(buf);
+	}
 
 	return QDF_STATUS_SUCCESS;
 }
@@ -4825,8 +5280,11 @@
 	error = wmi_unified_cmd_send(wmi_handle, buf, len,
 					 WMI_SET_PERIODIC_CHANNEL_STATS_CONFIG);
 
-	if (error)
+	if (error) {
 		WMI_LOGE(" %s :WMI Failed", __func__);
+		WMI_LOGE("Failed to send WMI_SET_PERIODIC_CHANNEL_STATS_CONFIG");
+		wmi_buf_free(buf);
+	}
 
 	return error;
 }
@@ -4842,13 +5300,19 @@
 send_nf_dbr_dbm_info_get_cmd_non_tlv(wmi_unified_t wmi_handle, uint8_t mac_id)
 {
 	wmi_buf_t wmibuf;
-
+	QDF_STATUS ret;
 	wmibuf = wmi_buf_alloc(wmi_handle, 0);
 	if (wmibuf == NULL)
 		return QDF_STATUS_E_NOMEM;
 
-	return wmi_unified_cmd_send(wmi_handle, wmibuf, 0,
+	ret = wmi_unified_cmd_send(wmi_handle, wmibuf, 0,
 				WMI_PDEV_GET_NFCAL_POWER_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_PDEV_GET_NFCAL_POWER_CMDID");
+		wmi_buf_free(wmibuf);
+	}
+
+	return ret;
 }
 
 /**
@@ -4946,6 +5410,7 @@
 {
 	wmi_pdev_get_tpc_cmd *cmd;
 	wmi_buf_t wmibuf;
+	QDF_STATUS ret;
 	u_int32_t len = sizeof(wmi_pdev_get_tpc_cmd);
 
 	wmibuf = wmi_buf_alloc(wmi_handle, len);
@@ -4964,8 +5429,15 @@
 		__func__, __LINE__, WMI_PDEV_GET_TPC_CMDID, *((u_int32_t *)cmd),
 		cmd->rate_flags, cmd->nss, cmd->preamble, cmd->hw_rate);
 
-	return wmi_unified_cmd_send(wmi_handle, wmibuf, len,
+	ret = wmi_unified_cmd_send(wmi_handle, wmibuf, len,
 				   WMI_PDEV_GET_TPC_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_PDEV_GET_TPC_CMDID");
+		wmi_buf_free(wmibuf);
+	}
+
+	return ret;
+
 }
 
 /**
@@ -4981,6 +5453,7 @@
 {
 	wmi_gpio_config_cmd *cmd;
 	wmi_buf_t wmibuf;
+	QDF_STATUS ret;
 	u_int32_t len = sizeof(wmi_gpio_config_cmd);
 
 	/* Sanity Checks */
@@ -4998,8 +5471,15 @@
 	cmd->input = param->input;
 	cmd->pull_type = param->pull_type;
 	cmd->intr_mode = param->intr_mode;
-	return wmi_unified_cmd_send(wmi_handle, wmibuf, len,
+	ret = wmi_unified_cmd_send(wmi_handle, wmibuf, len,
 		WMI_GPIO_CONFIG_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_GPIO_CONFIG_CMDID");
+		wmi_buf_free(wmibuf);
+	}
+
+	return ret;
+
 }
 
 /**
@@ -5015,6 +5495,7 @@
 {
 	wmi_gpio_output_cmd *cmd;
 	wmi_buf_t wmibuf;
+	QDF_STATUS ret;
 	u_int32_t len = sizeof(wmi_gpio_output_cmd);
 
 	wmibuf = wmi_buf_alloc(wmi_handle, len);
@@ -5024,8 +5505,15 @@
 	cmd = (wmi_gpio_output_cmd *)wmi_buf_data(wmibuf);
 	cmd->gpio_num = param->gpio_num;
 	cmd->set = param->set;
-	return wmi_unified_cmd_send(wmi_handle, wmibuf, len,
+	ret = wmi_unified_cmd_send(wmi_handle, wmibuf, len,
 		WMI_GPIO_OUTPUT_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_GPIO_OUTPUT_CMDID");
+		wmi_buf_free(wmibuf);
+	}
+
+	return ret;
+
 }
 
 /*
@@ -5143,6 +5631,11 @@
 	ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_RTT_MEASREQ_CMDID);
 	WMI_LOGD("send rtt cmd to FW with length %d and return %d",
 		  len, ret);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_RTT_MEASREQ_CMDID");
+		wmi_buf_free(buf);
+	}
+
 	return QDF_STATUS_SUCCESS;
 }
 
@@ -5281,6 +5774,11 @@
 	ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_RTT_MEASREQ_CMDID);
 	WMI_LOGD("send rtt cmd to FW with length %d and return %d",
 		  len, ret);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_RTT_MEASREQ_CMDID");
+		wmi_buf_free(buf);
+	}
+
 	return ret;
 }
 /**
@@ -5328,6 +5826,10 @@
 	WMI_LOGD("send rtt keepalive cmd to FW with length %d and return %d\n"
 		, len, ret);
 	param->req_id++;
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_RTT_KEEPALIVE_CMDID");
+		wmi_buf_free(buf);
+	}
 
 	return QDF_STATUS_SUCCESS;
 }
@@ -5384,8 +5886,10 @@
 
 	head = (wmi_oem_measreq_head *)p;
 	WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(head, param->lci_data, len);
-	if (wmi_unified_cmd_send(wmi_handle, buf, len, WMI_OEM_REQ_CMDID))
+	if (wmi_unified_cmd_send(wmi_handle, buf, len, WMI_OEM_REQ_CMDID)) {
+		wmi_buf_free(buf);
 		return QDF_STATUS_E_FAILURE;
+	}
 
 	/* Save LCI data in host buffer */
 	{
@@ -5453,8 +5957,10 @@
 	head = (wmi_oem_measreq_head *)p;
 	WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(head, param->lcr_data, len);
 
-	if (wmi_unified_cmd_send(wmi_handle, buf, len, WMI_OEM_REQ_CMDID))
+	if (wmi_unified_cmd_send(wmi_handle, buf, len, WMI_OEM_REQ_CMDID)) {
+		wmi_buf_free(buf);
 		return QDF_STATUS_E_FAILURE;
+	}
 
 	return QDF_STATUS_SUCCESS;
 }
@@ -8899,6 +9405,7 @@
 {
 	wmi_peer_remove_all_wds_entries_cmd *cmd;
 	wmi_buf_t buf;
+	QDF_STATUS ret;
 	int len = sizeof(wmi_peer_remove_all_wds_entries_cmd);
 
 	buf = wmi_buf_alloc(wmi_handle, len);
@@ -8916,8 +9423,14 @@
 	if (param->peer_macaddr)
 		WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr,
 						&cmd->peer_macaddr);
-	return wmi_unified_cmd_send(wmi_handle, buf, len,
+	ret = wmi_unified_cmd_send(wmi_handle, buf, len,
 			WMI_PEER_REMOVE_ALL_WDS_ENTRIES_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_PEER_REMOVE_ALL_WDS_ENTRIES_CMDID");
+		wmi_buf_free(buf);
+	}
+
+	return ret;
 }
 
 /**
@@ -8935,6 +9448,7 @@
 {
 	int i;
 	wmi_buf_t buf;
+	QDF_STATUS ret;
 	wmi_channel *chan_info;
 	struct mlme_channel_param *tchan_info;
 	wmi_pdev_multiple_vdev_restart_request_cmd *cmd;
@@ -8995,9 +9509,17 @@
 	WMI_LOGI("maxregpower:%d reg_class_id:%d",
 		 tchan_info->maxregpower, tchan_info->reg_class_id);
 
-	return wmi_unified_cmd_send(
+	ret = wmi_unified_cmd_send(
 			wmi_handle, buf, len,
 			WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID);
+	if (QDF_IS_STATUS_ERROR(ret)) {
+		WMI_LOGE("Failed to send WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID");
+		wmi_buf_free(buf);
+	}
+	return ret;
+
+
+
 }
 
 /**