浏览代码

Bluetooth: Fix lookup of fixed channels by local bdaddr

The comparing of chan->src should always be done against the local
identity address, represented by hcon->src and hcon->src_type. This
patch modifies l2cap_global_fixed_chan() to take the full hci_conn so
that we can easily compare against hcon->src and hcon->src_type.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Johan Hedberg 10 年之前
父节点
当前提交
327a71910c
共有 1 个文件被更改,包括 7 次插入8 次删除
  1. 7 8
      net/bluetooth/l2cap_core.c

+ 7 - 8
net/bluetooth/l2cap_core.c

@@ -7207,8 +7207,10 @@ int l2cap_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr)
  * global list (by passing NULL as first parameter).
  * global list (by passing NULL as first parameter).
  */
  */
 static struct l2cap_chan *l2cap_global_fixed_chan(struct l2cap_chan *c,
 static struct l2cap_chan *l2cap_global_fixed_chan(struct l2cap_chan *c,
-						  bdaddr_t *src, u8 link_type)
+						  struct hci_conn *hcon)
 {
 {
+	u8 src_type = bdaddr_src_type(hcon);
+
 	read_lock(&chan_list_lock);
 	read_lock(&chan_list_lock);
 
 
 	if (c)
 	if (c)
@@ -7221,11 +7223,9 @@ static struct l2cap_chan *l2cap_global_fixed_chan(struct l2cap_chan *c,
 			continue;
 			continue;
 		if (c->state != BT_LISTEN)
 		if (c->state != BT_LISTEN)
 			continue;
 			continue;
-		if (bacmp(&c->src, src) && bacmp(&c->src, BDADDR_ANY))
-			continue;
-		if (link_type == ACL_LINK && c->src_type != BDADDR_BREDR)
+		if (bacmp(&c->src, &hcon->src) && bacmp(&c->src, BDADDR_ANY))
 			continue;
 			continue;
-		if (link_type == LE_LINK && c->src_type == BDADDR_BREDR)
+		if (src_type != c->src_type)
 			continue;
 			continue;
 
 
 		l2cap_chan_hold(c);
 		l2cap_chan_hold(c);
@@ -7267,7 +7267,7 @@ void l2cap_connect_cfm(struct hci_conn *hcon, u8 status)
 	 * we left off, because the list lock would prevent calling the
 	 * we left off, because the list lock would prevent calling the
 	 * potentially sleeping l2cap_chan_lock() function.
 	 * potentially sleeping l2cap_chan_lock() function.
 	 */
 	 */
-	pchan = l2cap_global_fixed_chan(NULL, &hdev->bdaddr, hcon->type);
+	pchan = l2cap_global_fixed_chan(NULL, hcon);
 	while (pchan) {
 	while (pchan) {
 		struct l2cap_chan *chan, *next;
 		struct l2cap_chan *chan, *next;
 
 
@@ -7288,8 +7288,7 @@ void l2cap_connect_cfm(struct hci_conn *hcon, u8 status)
 
 
 		l2cap_chan_unlock(pchan);
 		l2cap_chan_unlock(pchan);
 next:
 next:
-		next = l2cap_global_fixed_chan(pchan, &hdev->bdaddr,
-					       hcon->type);
+		next = l2cap_global_fixed_chan(pchan, hcon);
 		l2cap_chan_put(pchan);
 		l2cap_chan_put(pchan);
 		pchan = next;
 		pchan = next;
 	}
 	}