Skip to contentSkip to conversation

Bluetooth: Fix missing channel unlock in l2cap_le_credits

PATCH In review Martin Townsend 4 participants 4 messages Oct 13, 2014 – Oct 17, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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
index 46547b9..bfb6af8 100644
@@ -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
Tested-by on v1 1/1
#1 lore raw

Hi,

Quoted 13 lines · Martin Townsend

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 +0 -0
index 46547b9..bfb6af8 100644

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

#2 lore raw

Hi Jukka,

Quoted 19 lines · Jukka Rissanen
Quoted 18 lines · Martin Townsend

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
index 46547b9..bfb6af8 100644
@@ -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

Thanks for testing!

Johan