task: Destroy zero mars context ptr

This patch zero's the task id MARS context pointer to invalidate the task id
when before a task is created and after it is destroyed to catch some cases
where the user tries to use an invalid task id.

Signed-off-by: Yuji Mano <yuji.mano@am.sony.com>
Acked-by: Kazunori Asayama <asayama@sm.sony.co.jp>
diff --git a/task/include/host/mars/task.h b/task/include/host/mars/task.h
index 5157088..ef069fa 100644
--- a/task/include/host/mars/task.h
+++ b/task/include/host/mars/task.h
@@ -139,7 +139,7 @@
  * \n	MARS_ERROR_PARAMS	- bad task id specified
  * \n	MARS_ERROR_STATE	- task is in an invalid state
  */
-int mars_task_destroy(const struct mars_task_id *id);
+int mars_task_destroy(struct mars_task_id *id);
 
 /**
  * \ingroup group_mars_task
diff --git a/task/src/host/lib/task.c b/task/src/host/lib/task.c
index 15272a3..51562ef 100644
--- a/task/src/host/lib/task.c
+++ b/task/src/host/lib/task.c
@@ -172,6 +172,9 @@
 	if (context_save_size > MARS_TASK_CONTEXT_SAVE_SIZE_MAX)
 		return MARS_ERROR_PARAMS;
 
+	/* invalidate id */
+	id_ret->mars_context_ea = 0;
+
 	/* begin process to add the task to the workload queue */
 	ret = mars_workload_queue_add_begin(mars, &workload_id, &workload_ea,
 					    mars_task_module_entry,
@@ -234,7 +237,7 @@
 	return MARS_SUCCESS;
 }
 
-int mars_task_destroy(const struct mars_task_id *id)
+int mars_task_destroy(struct mars_task_id *id)
 {
 	int ret;
 	struct mars_context *mars;
@@ -272,6 +275,9 @@
 	mars_ea_unmap(task->text_ea, task->text_size);
 	mars_ea_unmap(task->data_ea, task->data_size);
 
+	/* invalidate id */
+	id->mars_context_ea = 0;
+
 	/* end process to remove the task from the workload queue */
 	return mars_workload_queue_remove_end(mars, id->workload_id, 0);
 }