Skip to contentSkip to conversation

Bluetooth: properly initialize conn_params in scan phase

PATCH Superseded Jakub Pawlowski 1 participant 1 message Oct 15, 2015

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Bluetooth: properly initialize conn_params in scan phase

This patch makes sure that conn_params that were created just for explicit_connect, will get properly deleted during cleanup.

---
 net/bluetooth/hci_conn.c | 22 +++++++++++++++-------
 net/bluetooth/mgmt.c     |  3 +++
 2 files changed, 18 insertions(+), 7 deletions(-)
net/bluetooth/hci_conn.c +15 -7
index dbe32db..42b083e 100644
@@ -1015,15 +1015,23 @@ static int hci_explicit_conn_params_set(struct hci_request *req,
 	if (is_connected(hdev, addr, addr_type))
 		return -EISCONN;
 
-	params = hci_conn_params_add(hdev, addr, addr_type);
-	if (!params)
-		return -EIO;
+	params = hci_conn_params_lookup(hdev, addr, addr_type);
+	if (!params) {
+		params = hci_conn_params_add(hdev, addr, addr_type);
+		if (!params)
+			return -EIO;
+
+		/* If we created new params, mark them to be deleted in
+		 * hci_connect_le_scan_cleanup. It's different case than
+		 * existing disabled params, those will stay after cleanup.
+		 */
+		params->auto_connect = HCI_AUTO_CONN_EXPLICIT;
+	}
 
-	/* If we created new params, or existing params were marked as disabled,
-	 * mark them to be used just once to connect.
-	 */
+	/* We're trying to connect, so make sure params are at pend_le_conns */
 	if (params->auto_connect == HCI_AUTO_CONN_DISABLED ||
-	    params->auto_connect == HCI_AUTO_CONN_REPORT) {
+	    params->auto_connect == HCI_AUTO_CONN_REPORT ||
+	    params->auto_connect == HCI_AUTO_CONN_EXPLICIT) {
 		list_del_init(&params->action);
 		list_add(&params->action, &hdev->pend_le_conns);
 	}
net/bluetooth/mgmt.c +3 -0
index 9216393..61df34f 100644
@@ -3584,6 +3584,9 @@ static int pair_device(struct sock *sk, struct hci_dev *hdev, void *data,
 		 */
 		hci_conn_params_add(hdev, &cp->addr.bdaddr, addr_type);
 
+		if (hci_param->auto_connect == HCI_AUTO_CONN_EXPLICIT)
+			hci_param->auto_connect = HCI_AUTO_CONN_DISABLED;
+
 		conn = hci_connect_le_scan(hdev, &cp->addr.bdaddr,
 					   addr_type, sec_level,
 					   HCI_LE_CONN_TIMEOUT,
Signature · 1 line
2.5.0