Skip to content

Commit

Permalink
irq/work: Use llist_for_each_entry_safe
Browse files Browse the repository at this point in the history
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 <chris@chris-wilson.co.uk>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Frederic Weisbecker <frederic@kernel.org>
Cc: Byungchul Park <byungchul.park@lge.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Petri Latvala <petri.latvala@intel.com>
Link: http://lkml.kernel.org/r/151027307351.14762.4611888896020658384@mail.alporthouse.com
  • Loading branch information
KAGA-KOKO committed Nov 12, 2017
1 parent 9dc505d commit d00a08c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions kernel/irq_work.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,17 +128,17 @@ bool irq_work_needs_cpu(void)

static void irq_work_run_list(struct llist_head *list)
{
unsigned long flags;
struct irq_work *work;
struct irq_work *work, *tmp;
struct llist_node *llnode;
unsigned long flags;

BUG_ON(!irqs_disabled());

if (llist_empty(list))
return;

llnode = llist_del_all(list);
llist_for_each_entry(work, llnode, llnode) {
llist_for_each_entry_safe(work, tmp, llnode, llnode) {
/*
* Clear the PENDING bit, after this point the @work
* can be re-used.
Expand Down

0 comments on commit d00a08c

Please sign in to comment.