Abhishek Pandit-Subedi
4e8c36c3b0
Bluetooth: Fix suspend notifier race
Unregister from suspend notifications and cancel suspend preparations
before running hci_dev_do_close. Otherwise, the suspend notifier may
race with unregister and cause cmd_timeout even after hdev has been
freed.
Below is the trace from when this panic was seen:
[ 832.578518] Bluetooth: hci_core.c:hci_cmd_timeout() hci0: command 0x0c05 tx timeout
[ 832.586200] BUG: kernel NULL pointer dereference, address: 0000000000000000
[ 832.586203] #PF: supervisor read access in kernel mode
[ 832.586205] #PF: error_code(0x0000) - not-present page
[ 832.586206] PGD 0 P4D 0
[ 832.586210] PM: suspend exit
[ 832.608870] Oops: 0000 [#1] PREEMPT SMP NOPTI
[ 832.613232] CPU: 3 PID: 10755 Comm: kworker/3:7 Not tainted 5.4.44-04894-g1e9dbb96a161 #1
[ 832.630036] Workqueue: events hci_cmd_timeout [bluetooth]
[ 832.630046] RIP: 0010:__queue_work+0xf0/0x374
[ 832.630051] RSP: 0018:ffff9b5285f1fdf8 EFLAGS: 00010046
[ 832.674033] RAX: ffff8a97681bac00 RBX: 0000000000000000 RCX: ffff8a976a000600
[ 832.681162] RDX: 0000000000000000 RSI: 0000000000000009 RDI: ffff8a976a000748
[ 832.688289] RBP: ffff9b5285f1fe38 R08: 0000000000000000 R09: ffff8a97681bac00
[ 832.695418] R10: 0000000000000002 R11: ffff8a976a0006d8 R12: ffff8a9745107600
[ 832.698045] usb 1-6: new full-speed USB device number 119 using xhci_hcd
[ 832.702547] R13: ffff8a9673658850 R14: 0000000000000040 R15: 000000000000001e
[ 832.702549] FS: 0000000000000000(0000) GS:ffff8a976af80000(0000) knlGS:0000000000000000
[ 832.702550] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 832.702550] CR2: 0000000000000000 CR3: 000000010415a000 CR4: 00000000003406e0
[ 832.702551] Call Trace:
[ 832.702558] queue_work_on+0x3f/0x68
[ 832.702562] process_one_work+0x1db/0x396
[ 832.747397] worker_thread+0x216/0x375
[ 832.751147] kthread+0x138/0x140
[ 832.754377] ? pr_cont_work+0x58/0x58
[ 832.758037] ? kthread_blkcg+0x2e/0x2e
[ 832.761787] ret_from_fork+0x22/0x40
[ 832.846191] ---[ end trace fa93f466da517212 ]---
Fixes: 9952d90ea2 ("Bluetooth: Handle PM_SUSPEND_PREPARE and PM_POST_SUSPEND")
Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2020-07-28 20:27:14 +02:00
..
2020-02-28 08:30:02 +01:00
2019-05-21 10:50:46 +02:00
2020-01-29 19:50:44 +01:00
2020-07-10 19:09:42 +02:00
2020-06-23 14:30:07 +02:00
2019-06-05 17:36:37 +02:00
2020-02-28 08:30:02 +01:00
2020-06-12 15:08:49 +02:00
2019-06-05 17:36:37 +02:00
2019-06-05 17:36:37 +02:00
2017-10-06 20:35:47 +02:00
2017-10-06 20:35:47 +02:00
2020-07-15 15:16:09 +02:00
2020-07-28 20:27:14 +02:00
2020-04-07 18:32:21 +02:00
2015-02-15 18:54:13 +02:00
2020-07-13 18:40:58 +02:00
2020-07-15 15:16:09 +02:00
2020-07-15 15:16:09 +02:00
2020-07-10 19:09:42 +02:00
2017-11-04 09:26:51 +09:00
2020-07-10 19:21:03 +02:00
2020-07-10 19:09:42 +02:00
2020-07-10 19:09:42 +02:00
2019-06-19 17:09:55 +02:00
2019-06-19 17:09:55 +02:00
2020-05-11 12:16:27 +02:00
2020-06-12 21:41:07 +02:00
2020-07-07 17:37:03 +02:00
2020-06-18 13:11:03 +03:00
2017-06-16 11:48:40 -04:00
2015-03-17 18:03:08 +01:00
2020-07-15 15:16:09 +02:00
2020-06-18 13:11:21 +03:00
2020-06-18 13:11:21 +03:00
2020-06-12 15:08:49 +02:00
2017-10-06 21:49:13 +03:00
2014-12-30 08:53:55 +02:00
2020-07-10 19:09:42 +02:00
2018-09-26 12:39:32 +03:00