From e695d462f82f64f567aadbdbe9d4c2389a406321 Mon Sep 17 00:00:00 2001
From: Torsten Polle <Torsten.Polle@gmx.de>
Date: Fri, 7 Mar 2014 14:37:11 -0600
Subject: [PATCH 6/8] Fix: Crash when canceling task work.
As the elements of the list __stp_tf_task_work_list are removed from
the list, a safe iteration has to be used in __stp_tf_cancel_task_work().
---
runtime/linux/task_finder2.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/runtime/linux/task_finder2.c b/runtime/linux/task_finder2.c
index 16fda87..e8f33a3 100644
--- a/runtime/linux/task_finder2.c
+++ b/runtime/linux/task_finder2.c
@@ -169,11 +169,12 @@ static void __stp_tf_free_task_work(struct task_work *work)
static void __stp_tf_cancel_task_work(void)
{
struct __stp_tf_task_work *node;
+ struct __stp_tf_task_work *tmp;
unsigned long flags;
// Cancel all remaining requests.
spin_lock_irqsave(&__stp_tf_task_work_list_lock, flags);
- list_for_each_entry(node, &__stp_tf_task_work_list, list) {
+ list_for_each_entry_safe(node, tmp, &__stp_tf_task_work_list, list) {
// Remove the item from the list, cancel it, then free it.
list_del(&node->list);
stp_task_work_cancel(node->task, node->work.func);
--
1.8.3.1