Bluetooth: Fix missing channel unlock in l2cap_le_credits
Subsystems (2)
PATCH 1/1 Bluetooth: Fix missing channel unlock in l2cap_le_credits
In the error case where credits is greater than max_credits there is a missing l2cap_chan_unlock before returning.
--- net/bluetooth/l2cap_core.c | 1 + 1 file changed, 1 insertion(+)
net/bluetooth/l2cap_core.c +1 -0
@@ -5544,6 +5544,7 @@ static inline int l2cap_le_credits(struct l2cap_conn *conn,if (credits > max_credits) {BT_ERR ("LE credits overflow" );l2cap_send_disconn_req (chan,ECONNRESET ); +l2cap_chan_unlock (chan);/* Return 0 so that we don't trigger an unnecessary * command reject packet.
Signature · 1 line
1.9.1
Hi,
Quoted 13 lines · Martin Townsend
In the error case where credits is greater than
max_creditsthere is a missingl2cap_chan_unlockbefore returning.Signed-off-by Martin Townsend <[email protected]>--- net/bluetooth/l2cap_core.c | 1 + 1 file changed, 1 insertion(+)net/bluetooth/l2cap_core.c +0
-0
net/bluetooth/l2cap_core.c static inline int l2cap_le_credits(struct l2cap_conn *conn, · line 5550
Quoted 7 lines
net/bluetooth/l2cap_core.c +1
-0@@ -5544,6 +5544,7 @@ static inline int l2cap_le_credits(struct l2cap_conn *conn,if (credits > max_credits) {BT_ERR ("LE credits overflow" );l2cap_send_disconn_req (chan,ECONNRESET ); +l2cap_chan_unlock (chan);/* Return 0 so that we don't trigger an unnecessary * command reject packet.
I did some testing with this patch and although it did not fix the inconsistent lock issue I am seeing, it did fix the mutex hang. I have two locking issue and this patch fixed the other one.
Cheers,
Jukka
Hi Jukka,
Quoted 19 lines · Jukka Rissanen
Quoted 18 lines · Martin Townsend
In the error case where credits is greater than
max_creditsthere is a missingl2cap_chan_unlockbefore returning.Signed-off-by Martin Townsend <[email protected]>--- net/bluetooth/l2cap_core.c | 1 + 1 file changed, 1 insertion(+)net/bluetooth/l2cap_core.c +1
-0@@ -5544,6 +5544,7 @@ static inline int l2cap_le_credits(struct l2cap_conn *conn,if (credits > max_credits) {BT_ERR ("LE credits overflow" );l2cap_send_disconn_req (chan,ECONNRESET ); +l2cap_chan_unlock (chan);
Quoted 6 lines
net/bluetooth/l2cap_core.c static inline int l2cap_le_credits(struct l2cap_conn *conn, · line 5550
Quoted 2 lines
net/bluetooth/l2cap_core.c +0
-0/* Return 0 so that we don't trigger an unnecessary * command reject packet. I did some testing with this patch and although it did not fix the inconsistent lock issue I am seeing, it did fix the mutex hang. I have two locking issue and this patch fixed the other one.
When this code branch is taken it means that the remote side is not behaving properly and is sending a ridiculous amount of credits. It's worth investigating this further to fix such an issue (assuming that other side is also running BlueZ).
Quoted 1 line
Tested-by Jukka Rissanen <[email protected]>
Thanks for testing!
Johan
Marcel Holtmann
maintainerHi Martin,
Quoted 7 lines
In the error case where credits is greater than
max_creditsthere is a missingl2cap_chan_unlockbefore returning.Signed-off-by Martin Townsend <[email protected]>---
net/bluetooth/l2cap_core.c| 1 +1 file changed, 1 insertion(+)
patch has been applied to bluetooth-next tree.
Regards
Marcel