Skip to contentSkip to conversation

Bluetooth: Fix L2CAP nesting level initialization location

PATCH In review Johan Hedberg 2 participants 4 messages Nov 13, 2014

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

PATCH 1/2 Bluetooth: Fix L2CAP nesting level initialization location

From: Johan Hedberg <[email protected]>

There's no reason why all users of L2CAP would need to worry about initializing chan->nesting to L2CAP_NESTING_NORMAL (which is important since 0 is the same as NESTING_SMP). This patch moves the initialization to the common place that's used to create all new channels, i.e. the l2cap_chan_create() function.

---
 net/bluetooth/l2cap_core.c | 3 +++
 net/bluetooth/l2cap_sock.c | 3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)
net/bluetooth/l2cap_core.c +3 -0
index fc15174c612c..52e1871d6334 100644
@@ -424,6 +424,9 @@ struct l2cap_chan *l2cap_chan_create(void)
 
 	mutex_init(&chan->lock);
 
+	/* Set default lock nesting level */
+	atomic_set(&chan->nesting, L2CAP_NESTING_NORMAL);
+
 	write_lock(&chan_list_lock);
 	list_add(&chan->global_l, &chan_list);
 	write_unlock(&chan_list_lock);
net/bluetooth/l2cap_sock.c +0 -3
index 7913c28c643d..a5aa9f92b5e2 100644
@@ -1510,9 +1510,6 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent)
 		l2cap_chan_set_defaults(chan);
 	}
 
-	/* Set default lock nesting level */
-	atomic_set(&chan->nesting, L2CAP_NESTING_NORMAL);
-
 	/* Default config options */
 	chan->flush_to = L2CAP_DEFAULT_FLUSH_TO;
 
Signature · 1 line
2.1.0
#1 lore raw

PATCH 2/2 Bluetooth: Fix correct nesting for 6lowpan server channel

From: Johan Hedberg <[email protected]>

Server channels in BT_LISTEN state should use L2CAP_NESTING_PARENT. This patch fixes the nesting value for the 6lowpan channel.

---
 net/bluetooth/6lowpan.c | 2 ++
 1 file changed, 2 insertions(+)
net/bluetooth/6lowpan.c +2 -0
index 3d8ceb251d75..bdcaefd2db12 100644
@@ -1130,6 +1130,8 @@ static struct l2cap_chan *bt_6lowpan_listen(void)
 	pchan->state = BT_LISTEN;
 	pchan->src_type = BDADDR_LE_PUBLIC;
 
+	atomic_set(&pchan->nesting, L2CAP_NESTING_PARENT);
+
 	BT_DBG("psm 0x%04x chan %p src type %d", psm_6lowpan, pchan,
 	       pchan->src_type);
 
Signature · 1 line
2.1.0
maintainer
#2 lore raw

Re: [PATCH 2/2] Bluetooth: Fix correct nesting for 6lowpan server channel

Hi Johan,

Quoted 7 lines

Server channels in BT_LISTEN state should use L2CAP_NESTING_PARENT. This patch fixes the nesting value for the 6lowpan channel.

---
net/bluetooth/6lowpan.c | 2 ++

1 file changed, 2 insertions(+)

patch has been applied to bluetooth-next tree.

Regards

Marcel

maintainer
#3 lore raw
In reply to Johan Hedberg

Hi Johan,

Quoted 11 lines

There's no reason why all users of L2CAP would need to worry about initializing chan->nesting to L2CAP_NESTING_NORMAL (which is important since 0 is the same as NESTING_SMP). This patch moves the initialization to the common place that's used to create all new channels, i.e. the l2cap_chan_create() function.

---
net/bluetooth/l2cap_core.c | 3 +++
net/bluetooth/l2cap_sock.c | 3 ---

2 files changed, 3 insertions(+), 3 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel