diff options
author | Yuji Mano <yuji.mano@am.sony.com> | 2009-03-26 15:44:51 -0700 |
---|---|---|
committer | Yuji Mano <yuji.mano@am.sony.com> | 2009-03-26 17:24:20 -0700 |
commit | 4f83d8c84dad047d085cc5a99c960dbcda854e4b (patch) | |
tree | 3bdf0c63a2b7ec856a2bf14fe0e29d1f1bbf16d3 | |
parent | 229907a0697aa203686ce18260a05564adb4f820 (diff) | |
download | mars-src-4f83d8c84dad047d085cc5a99c960dbcda854e4b.tar.gz |
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>
-rw-r--r-- | task/include/host/mars/task.h | 2 | ||||
-rw-r--r-- | task/src/host/lib/task.c | 8 |
2 files changed, 8 insertions, 2 deletions
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 @@ int mars_task_create(struct mars_context *mars, * \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 @@ int mars_task_create(struct mars_context *mars, 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 *mars, 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_task_id *id) 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); } |