From 9782763db2ebdaeab23c6047a0a4910ff1bb5d59 Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Mon, 21 Dec 2015 12:13:03 +0000 Subject: [PATCH] In the zero delay case in queue_delayed_work() use the return value from taskqueue_enqueue() instead of reading "ta_pending" unlocked and also ensure the callout is stopped before proceeding. MFC after: 1 week Sponsored by: Mellanox Technologies --- sys/compat/linuxkpi/common/include/linux/workqueue.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/workqueue.h b/sys/compat/linuxkpi/common/include/linux/workqueue.h index 9903610d0f47..5a2c14f63946 100644 --- a/sys/compat/linuxkpi/common/include/linux/workqueue.h +++ b/sys/compat/linuxkpi/common/include/linux/workqueue.h @@ -105,13 +105,15 @@ queue_delayed_work(struct workqueue_struct *wq, struct delayed_work *work, { int pending; - pending = work->work.work_task.ta_pending; work->work.taskqueue = wq->taskqueue; - if (delay != 0) + if (delay != 0) { + pending = work->work.work_task.ta_pending; callout_reset(&work->timer, delay, linux_delayed_work_fn, work); - else - linux_delayed_work_fn((void *)work); - + } else { + callout_stop(&work->timer); + pending = taskqueue_enqueue(work->work.taskqueue, + &work->work.work_task); + } return (!pending); }