Skip to content

Commit d00a08c

Browse files
committed
irq/work: Use llist_for_each_entry_safe
The llist_for_each_entry() loop in irq_work_run_list() is unsafe because once the works PENDING bit is cleared it can be requeued on another CPU. Use llist_for_each_entry_safe() instead. Fixes: 16c0890 ("irq/work: Don't reinvent the wheel but use existing llist API") Reported-by:Chris Wilson <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: Frederic Weisbecker <[email protected]> Cc: Byungchul Park <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Petri Latvala <[email protected]> Link: http://lkml.kernel.org/r/[email protected]
1 parent 9dc505d commit d00a08c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

kernel/irq_work.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,17 +128,17 @@ bool irq_work_needs_cpu(void)
128128

129129
static void irq_work_run_list(struct llist_head *list)
130130
{
131-
unsigned long flags;
132-
struct irq_work *work;
131+
struct irq_work *work, *tmp;
133132
struct llist_node *llnode;
133+
unsigned long flags;
134134

135135
BUG_ON(!irqs_disabled());
136136

137137
if (llist_empty(list))
138138
return;
139139

140140
llnode = llist_del_all(list);
141-
llist_for_each_entry(work, llnode, llnode) {
141+
llist_for_each_entry_safe(work, tmp, llnode, llnode) {
142142
/*
143143
* Clear the PENDING bit, after this point the @work
144144
* can be re-used.

0 commit comments

Comments
 (0)