Bluetooth: Convert Pair Device to use cmd_complete callback
This patch converts the Pair Device mgmt command to use the new cmd_complete callback for pending mgmt commands. The already existing pairing_complete() function is exactly what's needed and doesn't need changing. In addition to getting the return parameters always right this patch actually fixes a reference counting bug and memory leak with the hci_conn that's attached to the pending mgmt command - something that would occur when powering off or unplugging the adapter while pairing is in progress. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
This commit is contained in:
parent
7776d1d805
commit
04ab2749ea
1 changed files with 5 additions and 3 deletions
|
@ -3129,7 +3129,7 @@ void mgmt_smp_complete(struct hci_conn *conn, bool complete)
|
||||||
|
|
||||||
cmd = find_pairing(conn);
|
cmd = find_pairing(conn);
|
||||||
if (cmd)
|
if (cmd)
|
||||||
pairing_complete(cmd, status);
|
cmd->cmd_complete(cmd, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pairing_complete_cb(struct hci_conn *conn, u8 status)
|
static void pairing_complete_cb(struct hci_conn *conn, u8 status)
|
||||||
|
@ -3142,7 +3142,7 @@ static void pairing_complete_cb(struct hci_conn *conn, u8 status)
|
||||||
if (!cmd)
|
if (!cmd)
|
||||||
BT_DBG("Unable to find a pending command");
|
BT_DBG("Unable to find a pending command");
|
||||||
else
|
else
|
||||||
pairing_complete(cmd, mgmt_status(status));
|
cmd->cmd_complete(cmd, mgmt_status(status));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void le_pairing_complete_cb(struct hci_conn *conn, u8 status)
|
static void le_pairing_complete_cb(struct hci_conn *conn, u8 status)
|
||||||
|
@ -3158,7 +3158,7 @@ static void le_pairing_complete_cb(struct hci_conn *conn, u8 status)
|
||||||
if (!cmd)
|
if (!cmd)
|
||||||
BT_DBG("Unable to find a pending command");
|
BT_DBG("Unable to find a pending command");
|
||||||
else
|
else
|
||||||
pairing_complete(cmd, mgmt_status(status));
|
cmd->cmd_complete(cmd, mgmt_status(status));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int pair_device(struct sock *sk, struct hci_dev *hdev, void *data,
|
static int pair_device(struct sock *sk, struct hci_dev *hdev, void *data,
|
||||||
|
@ -3255,6 +3255,8 @@ static int pair_device(struct sock *sk, struct hci_dev *hdev, void *data,
|
||||||
goto unlock;
|
goto unlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cmd->cmd_complete = pairing_complete;
|
||||||
|
|
||||||
/* For LE, just connecting isn't a proof that the pairing finished */
|
/* For LE, just connecting isn't a proof that the pairing finished */
|
||||||
if (cp->addr.type == BDADDR_BREDR) {
|
if (cp->addr.type == BDADDR_BREDR) {
|
||||||
conn->connect_cfm_cb = pairing_complete_cb;
|
conn->connect_cfm_cb = pairing_complete_cb;
|
||||||
|
|
Loading…
Reference in a new issue