[Cbe-oss-dev] [PATCH 2/2]MARS/task: destroy zero mars context ptr

Yuji Mano yuji.mano at am.sony.com
Fri Mar 27 09:44:51 EST 2009


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 at am.sony.com>
---
 task/include/host/mars/task.h |    2 +-
 task/src/host/lib/task.c      |    8 +++++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

--- a/task/include/host/mars/task.h
+++ b/task/include/host/mars/task.h
@@ -139,7 +139,7 @@ int mars_task_create(struct mars_context
  * \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
--- a/task/src/host/lib/task.c
+++ b/task/src/host/lib/task.c
@@ -172,6 +172,9 @@ int mars_task_create(struct mars_context
 	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 @@ int mars_task_create(struct mars_context
 	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 @@ int mars_task_destroy(const struct mars_
 	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);
 }






More information about the cbe-oss-dev mailing list