CHROMIUM: virtio/wl: Unlock vfd->lock before freeing it
Fix following lockdep splat:
[ 4.988698] =========================
[ 4.988699] WARNING: held lock freed!
[ 4.988703] 4.14.58-06411-gbfea9a5835f0 #12 Not tainted
[ 4.988703] -------------------------
[ 4.988706] allocator@2.0-s/112 is freeing memory ffff88002e62b000-ffff88002e62b1ff, with a lock still held there!
[ 4.988707] (&vfd->lock){+.+.}, at: [<ffffffff814c76ef>] virtwl_vfd_lock_unlink+0x2a/0x4b
[ 4.988742] 1 lock held by allocator@2.0-s/112:
[ 4.988743] #0: (&vfd->lock){+.+.}, at: [<ffffffff814c76ef>] virtwl_vfd_lock_unlink+0x2a/0x4b
[ 4.988746]
[ 4.988746] stack backtrace:
[ 4.988753] CPU: 0 PID: 112 Comm: allocator@2.0-s Not tainted 4.14.58-06411-gbfea9a5835f0 #12
[ 4.988755] Call Trace:
[ 4.988784] dump_stack+0x9f/0xd5
[ 4.988804] debug_check_no_locks_freed+0xf5/0x13c
[ 4.988815] slab_free_freelist_hook+0x34/0x79
[ 4.988824] kfree+0x16b/0x1da
[ 4.988829] ? do_vfd_close+0x16d/0x1a2
[ 4.988830] do_vfd_close+0x16d/0x1a2
[ 4.988843] virtwl_dmabuf_ops_release+0x13/0x2a
[ 4.988849] dma_buf_release+0x4c/0x133
[ 4.988863] __fput+0xe9/0x187
[ 4.988873] task_work_run+0x7a/0x9c
[ 4.988883] prepare_exit_to_usermode+0xd0/0x104
[ 4.988888] do_fast_syscall_32+0xc7/0xff
[ 4.988896] entry_SYSENTER_compat+0x84/0x96
BUG=none
TEST=Enable CONFIG_PROVE_LOCKING and observe no splat anymore
Change-Id: I55acd5c9d5c1fc41b9694ed91637a93f8d1c31d5
Signed-off-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1154234
Reviewed-by: Zach Reizner <zachr@chromium.org>
diff --git a/drivers/virtio/virtio_wl.c b/drivers/virtio/virtio_wl.c
index 61fee3a..2e09c4b 100644
--- a/drivers/virtio/virtio_wl.c
+++ b/drivers/virtio/virtio_wl.c
@@ -440,6 +440,7 @@
mutex_lock(&vi->vfds_lock);
mutex_lock(&vfd->lock);
idr_remove(&vi->vfds, vfd->id);
+ mutex_unlock(&vfd->lock);
mutex_unlock(&vi->vfds_lock);
}