diff mbox series

[git:media_tree/fixes] media: cec-adap.c: don't use flush_scheduled_work()

Message ID E1kGLHT-004CA3-5m@www.linuxtv.org
State New
Headers show
Series [git:media_tree/fixes] media: cec-adap.c: don't use flush_scheduled_work() | expand

Commit Message

Mauro Carvalho Chehab Sept. 10, 2020, 12:05 p.m. UTC
This is an automatic generated email to let you know that the following patch were queued:

Subject: media: cec-adap.c: don't use flush_scheduled_work()
Author:  Hans Verkuil <hverkuil-cisco@xs4all.nl>
Date:    Tue Sep 8 12:02:53 2020 +0200

For some inexplicable reason I decided to call flush_scheduled_work()
instead of cancel_delayed_work_sync(). The problem with that is that
flush_scheduled_work() waits for *all* queued scheduled work to be
completed instead of just the work itself.

This can cause a deadlock if a CEC driver also schedules work that
takes the same lock. See the comments for flush_scheduled_work() in
linux/workqueue.h.

This is exactly what has been observed a few times.

This patch simply replaces flush_scheduled_work() by
cancel_delayed_work_sync().

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Cc: <stable@vger.kernel.org>      # for v5.8 and up
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

 drivers/media/cec/core/cec-adap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

---
diff mbox series

Patch

diff --git a/drivers/media/cec/core/cec-adap.c b/drivers/media/cec/core/cec-adap.c
index 4efe8014445e..926d65db6d3e 100644
--- a/drivers/media/cec/core/cec-adap.c
+++ b/drivers/media/cec/core/cec-adap.c
@@ -1199,7 +1199,7 @@  void cec_received_msg_ts(struct cec_adapter *adap,
 			/* Cancel the pending timeout work */
 			if (!cancel_delayed_work(&data->work)) {
 				mutex_unlock(&adap->lock);
-				flush_scheduled_work();
+				cancel_delayed_work_sync(&data->work);
 				mutex_lock(&adap->lock);
 			}
 			/*