Commit 54a1b626 authored by Johan Hedberg's avatar Johan Hedberg Committed by Marcel Holtmann

Bluetooth: Improve fixed channel lookup based on link type

When notifying global fixed channels of new connections it doesn't make
sense to consider channels meant for a different link type than the one
available. This patch adds an extra parameter to the
l2cap_global_fixed_chan() lookup function and ensures that only channels
matching the current hci_conn type are looked up.
Signed-off-by: default avatarJohan Hedberg <johan.hedberg@intel.com>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent e760ec12
...@@ -7231,7 +7231,7 @@ int l2cap_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr) ...@@ -7231,7 +7231,7 @@ 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) bdaddr_t *src, u8 link_type)
{ {
read_lock(&chan_list_lock); read_lock(&chan_list_lock);
...@@ -7247,6 +7247,10 @@ static struct l2cap_chan *l2cap_global_fixed_chan(struct l2cap_chan *c, ...@@ -7247,6 +7247,10 @@ static struct l2cap_chan *l2cap_global_fixed_chan(struct l2cap_chan *c,
continue; continue;
if (bacmp(&c->src, src) && bacmp(&c->src, BDADDR_ANY)) if (bacmp(&c->src, src) && bacmp(&c->src, BDADDR_ANY))
continue; continue;
if (link_type == ACL_LINK && c->src_type != BDADDR_BREDR)
continue;
if (link_type == LE_LINK && c->src_type == BDADDR_BREDR)
continue;
l2cap_chan_hold(c); l2cap_chan_hold(c);
read_unlock(&chan_list_lock); read_unlock(&chan_list_lock);
...@@ -7287,7 +7291,7 @@ void l2cap_connect_cfm(struct hci_conn *hcon, u8 status) ...@@ -7287,7 +7291,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); pchan = l2cap_global_fixed_chan(NULL, &hdev->bdaddr, hcon->type);
while (pchan) { while (pchan) {
struct l2cap_chan *chan, *next; struct l2cap_chan *chan, *next;
...@@ -7308,7 +7312,8 @@ void l2cap_connect_cfm(struct hci_conn *hcon, u8 status) ...@@ -7308,7 +7312,8 @@ 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); next = l2cap_global_fixed_chan(pchan, &hdev->bdaddr,
hcon->type);
l2cap_chan_put(pchan); l2cap_chan_put(pchan);
pchan = next; pchan = next;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment