Pavel Skripkin 9d7cbe2b9c Bluetooth: hci_serdev: call init_rwsem() before p->open()
kvartet reported, that hci_uart_tx_wakeup() uses uninitialized rwsem.
The problem was in wrong place for percpu_init_rwsem() call.

hci_uart_proto::open() may register a timer whose callback may call
hci_uart_tx_wakeup(). There is a chance, that hci_uart_register_device()
thread won't be fast enough to call percpu_init_rwsem().

Fix it my moving percpu_init_rwsem() call before p->open().

INFO: trying to register non-static key.
The code is fine but needs lockdep annotation, or maybe
you didn't initialize this object before use?
turning off the locking correctness validator.
CPU: 2 PID: 18524 Comm: syz-executor.5 Not tainted 5.16.0-rc6 #9
...
Call Trace:
 <IRQ>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
 assign_lock_key kernel/locking/lockdep.c:951 [inline]
 register_lock_class+0x148d/0x1950 kernel/locking/lockdep.c:1263
 __lock_acquire+0x106/0x57e0 kernel/locking/lockdep.c:4906
 lock_acquire kernel/locking/lockdep.c:5637 [inline]
 lock_acquire+0x1ab/0x520 kernel/locking/lockdep.c:5602
 percpu_down_read_trylock include/linux/percpu-rwsem.h:92 [inline]
 hci_uart_tx_wakeup+0x12e/0x490 drivers/bluetooth/hci_ldisc.c:124
 h5_timed_event+0x32f/0x6a0 drivers/bluetooth/hci_h5.c:188
 call_timer_fn+0x1a5/0x6b0 kernel/time/timer.c:1421

Fixes: d73e17281665 ("Bluetooth: hci_serdev: Init hci_uart proto_lock to avoid oops")
Reported-by: Yiru Xu <xyru1999@gmail.com>
Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2022-01-21 23:46:48 +01:00
..
2021-11-26 19:45:31 +01:00
2021-11-06 14:36:12 -07:00
2021-11-01 10:09:14 -07:00
2021-12-22 10:11:17 -08:00
2021-11-03 17:00:52 -07:00
2021-11-08 11:49:48 -08:00
2021-12-13 13:18:48 +05:30
2021-11-05 08:42:02 -07:00
2021-11-04 13:56:55 -07:00
2021-11-26 22:54:47 +01:00
2021-12-17 11:46:07 -08:00
2021-11-22 14:58:57 -08:00
2021-11-06 14:36:12 -07:00
2021-11-10 11:36:43 -08:00
2021-10-26 19:12:01 +02:00
2021-11-10 10:56:02 -08:00
2021-10-18 09:29:27 +02:00
2021-11-02 15:58:39 -07:00
2021-12-24 08:58:23 -08:00
2021-11-08 12:07:52 -08:00
2021-11-10 09:07:26 -08:00
2021-11-12 11:44:31 -08:00
2021-12-31 09:22:25 -08:00
2021-12-16 15:02:26 +01:00
2021-12-20 10:23:19 -08:00
2021-12-23 09:22:34 -08:00
2021-11-30 11:41:49 -07:00
2021-12-05 09:13:20 -08:00
2021-11-10 09:41:22 -08:00
2021-12-08 14:53:15 -05:00