Commit 0809267
Bluetooth: 6lowpan: Don't hold spin lock over sleeping functions
[ Upstream commit 98454bc ]
disconnect_all_peers() calls sleeping function (l2cap_chan_close) under
spinlock. Holding the lock doesn't actually do any good -- we work on a
local copy of the list, and the lock doesn't protect against peer->chan
having already been freed.
Fix by taking refcounts of peer->chan instead. Clean up the code and
old comments a bit.
Take devices_lock instead of RCU, because the kfree_rcu();
l2cap_chan_put(); construct in chan_close_cb() does not guarantee
peer->chan is necessarily valid in RCU.
Also take l2cap_chan_lock() which is required for l2cap_chan_close().
Log: (bluez 6lowpan-tester Client Connect - Disable)
------
BUG: sleeping function called from invalid context at kernel/locking/mutex.c:575
...
<TASK>
...
l2cap_send_disconn_req (net/bluetooth/l2cap_core.c:938 net/bluetooth/l2cap_core.c:1495)
...
? __pfx_l2cap_chan_close (net/bluetooth/l2cap_core.c:809)
do_enable_set (net/bluetooth/6lowpan.c:1048 net/bluetooth/6lowpan.c:1068)
------
Fixes: 9030582 ("Bluetooth: 6lowpan: Converting rwlocks to use RCU")
Signed-off-by: Pauli Virtanen <pav@iki.fi>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit a5059df18988b242f1cda0b22a2b463509c59c04)
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>1 parent 7a68f3c commit 0809267
1 file changed
Lines changed: 43 additions & 25 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
55 | 60 | | |
56 | 61 | | |
57 | 62 | | |
| |||
60 | 65 | | |
61 | 66 | | |
62 | 67 | | |
| 68 | + | |
| 69 | + | |
63 | 70 | | |
64 | 71 | | |
65 | 72 | | |
| |||
1013 | 1020 | | |
1014 | 1021 | | |
1015 | 1022 | | |
1016 | | - | |
1017 | | - | |
1018 | | - | |
1019 | | - | |
| 1023 | + | |
| 1024 | + | |
1020 | 1025 | | |
1021 | | - | |
1022 | | - | |
1023 | | - | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
1024 | 1029 | | |
1025 | 1030 | | |
1026 | 1031 | | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
1027 | 1036 | | |
1028 | | - | |
1029 | | - | |
1030 | | - | |
1031 | | - | |
1032 | | - | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
1033 | 1040 | | |
1034 | | - | |
1035 | | - | |
| 1041 | + | |
1036 | 1042 | | |
1037 | | - | |
1038 | | - | |
1039 | | - | |
| 1043 | + | |
1040 | 1044 | | |
1041 | | - | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
1042 | 1050 | | |
1043 | | - | |
1044 | | - | |
1045 | | - | |
| 1051 | + | |
| 1052 | + | |
1046 | 1053 | | |
1047 | | - | |
1048 | | - | |
1049 | | - | |
1050 | | - | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
1051 | 1069 | | |
1052 | 1070 | | |
1053 | 1071 | | |
| |||
0 commit comments