Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eda42b50 authored by Andre Guedes's avatar Andre Guedes Committed by Gustavo Padovan
Browse files

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.

Signed-off-by: default avatarAndre Guedes <andre.guedes@openbossa.org>
Acked-by: default avatarVille Tervo <ville.tervo@nokia.com>
Signed-off-by: default avatarGustavo F. Padovan <padovan@profusion.mobi>
parent 893d6751
Loading
Loading
Loading
Loading
+9 −0
Original line number Original line Diff line number Diff line
@@ -447,13 +447,22 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8
	BT_DBG("%s dst %s", hdev->name, batostr(dst));
	BT_DBG("%s dst %s", hdev->name, batostr(dst));


	if (type == LE_LINK) {
	if (type == LE_LINK) {
		struct adv_entry *entry;

		le = hci_conn_hash_lookup_ba(hdev, LE_LINK, dst);
		le = hci_conn_hash_lookup_ba(hdev, LE_LINK, dst);
		if (le)
		if (le)
			return ERR_PTR(-EBUSY);
			return ERR_PTR(-EBUSY);

		entry = hci_find_adv_entry(hdev, dst);
		if (!entry)
			return ERR_PTR(-EHOSTUNREACH);

		le = hci_conn_add(hdev, LE_LINK, dst);
		le = hci_conn_add(hdev, LE_LINK, dst);
		if (!le)
		if (!le)
			return ERR_PTR(-ENOMEM);
			return ERR_PTR(-ENOMEM);


		le->dst_type = entry->bdaddr_type;

		hci_le_connect(le);
		hci_le_connect(le);


		hci_conn_hold(le);
		hci_conn_hold(le);