Commit 5157b8a5 authored by Jakub Pawlowski's avatar Jakub Pawlowski Committed by Marcel Holtmann

Bluetooth: Fix initializing 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.
Signed-off-by: default avatarJakub Pawlowski <jpawlowski@google.com>
Acked-by: default avatarJohan Hedberg <johan.hedberg@intel.com>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent 9ad3e6ff
...@@ -1008,15 +1008,23 @@ static int hci_explicit_conn_params_set(struct hci_request *req, ...@@ -1008,15 +1008,23 @@ static int hci_explicit_conn_params_set(struct hci_request *req,
if (is_connected(hdev, addr, addr_type)) if (is_connected(hdev, addr, addr_type))
return -EISCONN; return -EISCONN;
params = hci_conn_params_lookup(hdev, addr, addr_type);
if (!params) {
params = hci_conn_params_add(hdev, addr, addr_type); params = hci_conn_params_add(hdev, addr, addr_type);
if (!params) if (!params)
return -EIO; return -ENOMEM;
/* If we created new params, or existing params were marked as disabled, /* If we created new params, mark them to be deleted in
* mark them to be used just once to connect. * 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;
}
/* We're trying to connect, so make sure params are at pend_le_conns */
if (params->auto_connect == HCI_AUTO_CONN_DISABLED || 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_del_init(&params->action);
list_add(&params->action, &hdev->pend_le_conns); list_add(&params->action, &hdev->pend_le_conns);
} }
......
...@@ -3545,6 +3545,7 @@ static int pair_device(struct sock *sk, struct hci_dev *hdev, void *data, ...@@ -3545,6 +3545,7 @@ static int pair_device(struct sock *sk, struct hci_dev *hdev, void *data,
auth_type); auth_type);
} else { } else {
u8 addr_type; u8 addr_type;
struct hci_conn_params *p;
/* Convert from L2CAP channel address type to HCI address type /* Convert from L2CAP channel address type to HCI address type
*/ */
...@@ -3562,7 +3563,10 @@ static int pair_device(struct sock *sk, struct hci_dev *hdev, void *data, ...@@ -3562,7 +3563,10 @@ static int pair_device(struct sock *sk, struct hci_dev *hdev, void *data,
* If connection parameters already exist, then they * If connection parameters already exist, then they
* will be kept and this function does nothing. * will be kept and this function does nothing.
*/ */
hci_conn_params_add(hdev, &cp->addr.bdaddr, addr_type); p = hci_conn_params_add(hdev, &cp->addr.bdaddr, addr_type);
if (p->auto_connect == HCI_AUTO_CONN_EXPLICIT)
p->auto_connect = HCI_AUTO_CONN_DISABLED;
conn = hci_connect_le_scan(hdev, &cp->addr.bdaddr, conn = hci_connect_le_scan(hdev, &cp->addr.bdaddr,
addr_type, sec_level, addr_type, sec_level,
......
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