From: Andre Guedes Date: Tue, 31 May 2011 17:20:56 +0000 (-0300) Subject: Bluetooth: Check advertising cache in hci_connect() X-Git-Tag: firefly_0821_release~7613^2~523 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=5e89ece9dd1b6797078085519a8a52ec64511d24;p=firefly-linux-kernel-4.4.55.git Bluetooth: Check advertising cache in hci_connect() When connecting to a LE device, we need to check the advertising cache in order to know the address type of that device. If its advertising entry is not found, the connection is not established and hci_connect() returns error. Change-Id: I234912abc53b859becbe79625b08bc3b6eacc143 Signed-off-by: Andre Guedes Acked-by: Ville Tervo Signed-off-by: Gustavo F. Padovan --- diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 0903effaf7ef..1de9c1c2e365 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -458,13 +458,22 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, BT_DBG("%s dst %s", hdev->name, batostr(dst)); if (type == LE_LINK) { + struct adv_entry *entry; + le = hci_conn_hash_lookup_ba(hdev, LE_LINK, dst); if (le) return ERR_PTR(-EBUSY); + + entry = hci_find_adv_entry(hdev, dst); + if (!entry) + return ERR_PTR(-EHOSTUNREACH); + le = hci_conn_add(hdev, LE_LINK, 0, dst); if (!le) return ERR_PTR(-ENOMEM); + le->dst_type = entry->bdaddr_type; + hci_le_connect(le); hci_conn_hold(le);