Skip to contentSkip to conversation

Bluetooth: Initialize the TX queue lock when creating struct l2cap_chan in 6LOWPAN

PATCH In review Coiby Xu 2 participants 3 messages Aug 4, 2020

Subsystems (4)
lore
Share & tools
lore

Coiby Xu

author
#0 lore raw

PATCH 1/1 Bluetooth: Initialize the TX queue lock when creating struct l2cap_chan in 6LOWPAN

When L2CAP channel is destroyed by hci_unregister_dev, it will acquire the spin lock of the (struct l2cap_chan *)->tx_q list to delete all the buffers. But sometimes when hci_unregister_dev is being called, this lock may have not bee initialized. Initialize the TX queue lock when creating struct l2cap_chan in 6LOWPAN to fix this problem.

---
 net/bluetooth/6lowpan.c | 1 +
 1 file changed, 1 insertion(+)
net/bluetooth/6lowpan.c +1 -0
index bb55d92691b0..713c618a73df 100644
@@ -651,6 +651,7 @@ static struct l2cap_chan *chan_create(void)
 
 	l2cap_chan_set_defaults(chan);
 
+	skb_queue_head_init(&chan->tx_q);
 	chan->chan_type = L2CAP_CHAN_CONN_ORIENTED;
 	chan->mode = L2CAP_MODE_LE_FLOWCTL;
 	chan->imtu = 1280;
Signature · 1 line
2.27.0
#1 lore raw
Quoted 19 lines · Coiby Xu

When L2CAP channel is destroyed by hci_unregister_dev, it will acquire the spin lock of the (struct l2cap_chan *)->tx_q list to delete all the buffers. But sometimes when hci_unregister_dev is being called, this lock may have not bee initialized. Initialize the TX queue lock when creating struct l2cap_chan in 6LOWPAN to fix this problem.

---
 net/bluetooth/6lowpan.c | 1 +
 1 file changed, 1 insertion(+)
net/bluetooth/6lowpan.c +0 -0
index bb55d92691b0..713c618a73df 100644

net/bluetooth/6lowpan.c static struct l2cap_chan *chan_create(void) · line 657

Quoted 7 lines
net/bluetooth/6lowpan.c +1 -0
@@ -651,6 +651,7 @@ static struct l2cap_chan *chan_create(void)
 
 	l2cap_chan_set_defaults(chan);
 
+	skb_queue_head_init(&chan->tx_q);
 	chan->chan_type = L2CAP_CHAN_CONN_ORIENTED;
 	chan->mode = L2CAP_MODE_LE_FLOWCTL;
 	chan->imtu = 1280;

Nice, did syzbot verify that this resolves the issue?

thanks,

greg k-h

author
#2 lore raw
Quoted 30 lines · Greg KH
Quoted 19 lines · Coiby Xu

When L2CAP channel is destroyed by hci_unregister_dev, it will acquire the spin lock of the (struct l2cap_chan *)->tx_q list to delete all the buffers. But sometimes when hci_unregister_dev is being called, this lock may have not bee initialized. Initialize the TX queue lock when creating struct l2cap_chan in 6LOWPAN to fix this problem.

---
 net/bluetooth/6lowpan.c | 1 +
 1 file changed, 1 insertion(+)
net/bluetooth/6lowpan.c +0 -0
index bb55d92691b0..713c618a73df 100644

net/bluetooth/6lowpan.c static struct l2cap_chan *chan_create(void) · line 657

Quoted 7 lines
net/bluetooth/6lowpan.c +1 -0
@@ -651,6 +651,7 @@ static struct l2cap_chan *chan_create(void)
 
 	l2cap_chan_set_defaults(chan);
 
+	skb_queue_head_init(&chan->tx_q);
 	chan->chan_type = L2CAP_CHAN_CONN_ORIENTED;
 	chan->mode = L2CAP_MODE_LE_FLOWCTL;
 	chan->imtu = 1280;

Nice, did syzbot verify that this resolves the issue?

Quoted 3 lines

thanks,

greg k-h

Yes. Thank you for reminding me. I'll also add an Tested-by: tag next time.

--
Best regards,
Coiby