clear-pkgs-linux-iot-lts2018/1130-drivers-hyper_dmabuf-f...

91 lines
3.9 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Liu Xinyun <xinyun.liu@intel.com>
Date: Thu, 18 Jul 2019 11:22:51 +0800
Subject: [PATCH] drivers/hyper_dmabuf: fix dead lock in fastpath_export
dead lock was introduced when try to lock the unlocked lock.
hyper_dmabuf_export_remote_ioctl() | delayed_unexport()
mutex_lock() |
fastpath_export() |
cancel_delayed_work_sync() | mutex_lock()
10:22:08.031 I HwBinder: 2350_3 D 0 2616 1 0x00000004
10:22:08.031 W Call Trace:
10:22:08.031 W : __schedule+0x2a1/0x890
10:22:08.031 W : ? __switch_to_asm+0x34/0x70
10:22:08.031 W : ? __switch_to_asm+0x40/0x70
10:22:08.031 W : ? wait_for_completion+0x109/0x1a0
10:22:08.031 W : schedule+0x36/0x90
10:22:08.031 W : schedule_timeout+0x1fc/0x3a0
10:22:08.031 W : ? _raw_spin_unlock_irq+0x13/0x40
10:22:08.031 W : ? wait_for_completion+0x129/0x1a0
10:22:08.031 W : ? wait_for_completion+0x109/0x1a0
10:22:08.031 W : ? trace_hardirqs_on+0x38/0x100
10:22:08.031 W : ? wait_for_completion+0x109/0x1a0
10:22:08.031 W : wait_for_completion+0x131/0x1a0
10:22:08.031 W : ? wake_up_process+0x20/0x20
10:22:08.031 W : ? queue_rcu_work+0x30/0x30
10:22:08.031 W : __flush_work+0x12b/0x1e0
10:22:08.031 W : ? flush_workqueue_prep_pwqs+0x130/0x130
10:22:08.031 W : __cancel_work_timer+0x134/0x1d0
10:22:08.031 W : ? hyper_dmabuf_export_fd_ioctl+0x5b0/0x5b0
10:22:08.031 W : cancel_delayed_work_sync+0x13/0x20
10:22:08.031 W : hyper_dmabuf_export_remote_ioctl+0x1a9/0x6c0
10:22:08.031 W : ? hyper_dmabuf_export_fd_ioctl+0x5b0/0x5b0
10:22:08.031 W : hyper_dmabuf_ioctl+0x8d/0x160
10:22:08.031 W : do_vfs_ioctl+0xa9/0x6f0
10:22:08.031 W : ksys_ioctl+0x75/0x80
10:22:08.031 W : __x64_sys_ioctl+0x1a/0x20
10:22:08.031 W : do_syscall_64+0x55/0x110
10:22:08.031 W : entry_SYSCALL_64_after_hwframe+0x49/0xbe
10:22:08.032 I Workqueue: events delayed_unexport
10:22:08.032 W Call Trace:
10:22:08.032 W : __schedule+0x2a1/0x890
10:22:08.032 W : ? __mutex_lock.isra.3+0x1f3/0x820
10:22:08.032 W : schedule+0x36/0x90
10:22:08.032 W : schedule_preempt_disabled+0x18/0x30
10:22:08.032 W : __mutex_lock.isra.3+0x1e4/0x820
10:22:08.032 W : __mutex_lock_slowpath+0x13/0x20
10:22:08.032 W : ? __mutex_lock_slowpath+0x13/0x20
10:22:08.032 W : mutex_lock+0x3d/0x40
10:22:08.032 W : delayed_unexport+0x47/0x240
10:22:08.032 W : ? trace_hardirqs_on+0x38/0x100
10:22:08.032 W : process_one_work+0x19f/0x3e0
10:22:08.032 W : worker_thread+0x3f/0x3b0
10:22:08.032 W : kthread+0x12c/0x150
10:22:08.032 W : ? process_one_work+0x3e0/0x3e0
10:22:08.032 W : ? kthread_create_worker_on_cpu+0x70/0x70
10:22:08.032 W : ret_from_fork+0x3a/0x50
Change-Id: Iafdb450e33763f2b3a874bbe99d2b108acf4b76f
Tracked-On: OAM-84155
Signed-off-by: Min He <min.he@intel.com>
Signed-off-by: Liu Xinyun <xinyun.liu@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
---
drivers/dma-buf/hyper_dmabuf/hyper_dmabuf_ioctl.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/dma-buf/hyper_dmabuf/hyper_dmabuf_ioctl.c b/drivers/dma-buf/hyper_dmabuf/hyper_dmabuf_ioctl.c
index b18f70349021..712718df56a7 100644
--- a/drivers/dma-buf/hyper_dmabuf/hyper_dmabuf_ioctl.c
+++ b/drivers/dma-buf/hyper_dmabuf/hyper_dmabuf_ioctl.c
@@ -155,9 +155,12 @@ static int fastpath_export(hyper_dmabuf_id_t hid, int sz_priv, char *priv)
* to be reexport once again.
*/
if (exported->unexport_sched) {
+ mutex_unlock(&hy_drv_priv->lock);
+
if (!cancel_delayed_work_sync(&exported->unexport))
return reexport;
+ mutex_lock(&hy_drv_priv->lock);
exported->unexport_sched = false;
}
--
https://clearlinux.org