diff options
| author | Thomas Gleixner <[email protected]> | 2017-11-12 12:02:51 +0000 |
|---|---|---|
| committer | Thomas Gleixner <[email protected]> | 2017-11-12 12:15:14 +0000 |
| commit | d00a08cf9ee986ad6689ce8c6fd176aff679c106 (patch) | |
| tree | ad39bb22f22d5613e7c40b5e39552c334192dd46 | |
| parent | Merge tag 'irqchip-4.15-3' of git://git.kernel.org/pub/scm/linux/kernel/git/m... (diff) | |
| download | kernel-d00a08cf9ee986ad6689ce8c6fd176aff679c106.tar.gz kernel-d00a08cf9ee986ad6689ce8c6fd176aff679c106.zip | |
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: 16c0890dc66d ("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]
| -rw-r--r-- | kernel/irq_work.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/kernel/irq_work.c b/kernel/irq_work.c index e2ebe8c71e8f..6647b33f7eb0 100644 --- a/kernel/irq_work.c +++ b/kernel/irq_work.c @@ -128,9 +128,9 @@ 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()); @@ -138,7 +138,7 @@ static void irq_work_run_list(struct llist_head *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. |
