diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2014-12-11 14:45:45 -0500 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2014-12-11 14:57:38 -0500 |
commit | a511b35ba4f02cca526c7239723c48445a8b127d (patch) | |
tree | a5e333d603838860fdaee0eb3925594b38f3a05d /net | |
parent | 15013aeb63fb4df7ff809d63246c8398e9703736 (diff) |
Bluetooth: Fix incorrect pending cmd removal in pairing_complete()
The pairing_complete() function is used as a pending mgmt command
cmd_complete callback. The expectation of such functions is that they
are not responsible themselves for calling mgmt_pending_remove(). This
patch fixes the incorrect mgmt_pending_remove() call in
pairing_complete() and adds it to the appropriate changes.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net')
-rw-r--r-- | net/bluetooth/mgmt.c | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 34da65ccc888..827107d5a424 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
@@ -3115,7 +3115,6 @@ static void pairing_complete(struct pending_cmd *cmd, u8 status) | |||
3115 | conn->disconn_cfm_cb = NULL; | 3115 | conn->disconn_cfm_cb = NULL; |
3116 | 3116 | ||
3117 | hci_conn_drop(conn); | 3117 | hci_conn_drop(conn); |
3118 | mgmt_pending_remove(cmd); | ||
3119 | 3118 | ||
3120 | /* The device is paired so there is no need to remove | 3119 | /* The device is paired so there is no need to remove |
3121 | * its connection parameters anymore. | 3120 | * its connection parameters anymore. |
@@ -3131,8 +3130,10 @@ void mgmt_smp_complete(struct hci_conn *conn, bool complete) | |||
3131 | struct pending_cmd *cmd; | 3130 | struct pending_cmd *cmd; |
3132 | 3131 | ||
3133 | cmd = find_pairing(conn); | 3132 | cmd = find_pairing(conn); |
3134 | if (cmd) | 3133 | if (cmd) { |
3135 | cmd->cmd_complete(cmd, status); | 3134 | cmd->cmd_complete(cmd, status); |
3135 | mgmt_pending_remove(cmd); | ||
3136 | } | ||
3136 | } | 3137 | } |
3137 | 3138 | ||
3138 | static void pairing_complete_cb(struct hci_conn *conn, u8 status) | 3139 | static void pairing_complete_cb(struct hci_conn *conn, u8 status) |
@@ -3142,10 +3143,13 @@ static void pairing_complete_cb(struct hci_conn *conn, u8 status) | |||
3142 | BT_DBG("status %u", status); | 3143 | BT_DBG("status %u", status); |
3143 | 3144 | ||
3144 | cmd = find_pairing(conn); | 3145 | cmd = find_pairing(conn); |
3145 | if (!cmd) | 3146 | if (!cmd) { |
3146 | BT_DBG("Unable to find a pending command"); | 3147 | BT_DBG("Unable to find a pending command"); |
3147 | else | 3148 | return; |
3148 | cmd->cmd_complete(cmd, mgmt_status(status)); | 3149 | } |
3150 | |||
3151 | cmd->cmd_complete(cmd, mgmt_status(status)); | ||
3152 | mgmt_pending_remove(cmd); | ||
3149 | } | 3153 | } |
3150 | 3154 | ||
3151 | static void le_pairing_complete_cb(struct hci_conn *conn, u8 status) | 3155 | static void le_pairing_complete_cb(struct hci_conn *conn, u8 status) |
@@ -3158,10 +3162,13 @@ static void le_pairing_complete_cb(struct hci_conn *conn, u8 status) | |||
3158 | return; | 3162 | return; |
3159 | 3163 | ||
3160 | cmd = find_pairing(conn); | 3164 | cmd = find_pairing(conn); |
3161 | if (!cmd) | 3165 | if (!cmd) { |
3162 | BT_DBG("Unable to find a pending command"); | 3166 | BT_DBG("Unable to find a pending command"); |
3163 | else | 3167 | return; |
3164 | cmd->cmd_complete(cmd, mgmt_status(status)); | 3168 | } |
3169 | |||
3170 | cmd->cmd_complete(cmd, mgmt_status(status)); | ||
3171 | mgmt_pending_remove(cmd); | ||
3165 | } | 3172 | } |
3166 | 3173 | ||
3167 | static int pair_device(struct sock *sk, struct hci_dev *hdev, void *data, | 3174 | static int pair_device(struct sock *sk, struct hci_dev *hdev, void *data, |
@@ -3275,8 +3282,10 @@ static int pair_device(struct sock *sk, struct hci_dev *hdev, void *data, | |||
3275 | cmd->user_data = hci_conn_get(conn); | 3282 | cmd->user_data = hci_conn_get(conn); |
3276 | 3283 | ||
3277 | if ((conn->state == BT_CONNECTED || conn->state == BT_CONFIG) && | 3284 | if ((conn->state == BT_CONNECTED || conn->state == BT_CONFIG) && |
3278 | hci_conn_security(conn, sec_level, auth_type, true)) | 3285 | hci_conn_security(conn, sec_level, auth_type, true)) { |
3279 | pairing_complete(cmd, 0); | 3286 | cmd->cmd_complete(cmd, 0); |
3287 | mgmt_pending_remove(cmd); | ||
3288 | } | ||
3280 | 3289 | ||
3281 | err = 0; | 3290 | err = 0; |
3282 | 3291 | ||
@@ -3318,7 +3327,8 @@ static int cancel_pair_device(struct sock *sk, struct hci_dev *hdev, void *data, | |||
3318 | goto unlock; | 3327 | goto unlock; |
3319 | } | 3328 | } |
3320 | 3329 | ||
3321 | pairing_complete(cmd, MGMT_STATUS_CANCELLED); | 3330 | cmd->cmd_complete(cmd, MGMT_STATUS_CANCELLED); |
3331 | mgmt_pending_remove(cmd); | ||
3322 | 3332 | ||
3323 | err = cmd_complete(sk, hdev->id, MGMT_OP_CANCEL_PAIR_DEVICE, 0, | 3333 | err = cmd_complete(sk, hdev->id, MGMT_OP_CANCEL_PAIR_DEVICE, 0, |
3324 | addr, sizeof(*addr)); | 3334 | addr, sizeof(*addr)); |
@@ -6687,8 +6697,10 @@ void mgmt_auth_failed(struct hci_conn *conn, u8 hci_status) | |||
6687 | mgmt_event(MGMT_EV_AUTH_FAILED, conn->hdev, &ev, sizeof(ev), | 6697 | mgmt_event(MGMT_EV_AUTH_FAILED, conn->hdev, &ev, sizeof(ev), |
6688 | cmd ? cmd->sk : NULL); | 6698 | cmd ? cmd->sk : NULL); |
6689 | 6699 | ||
6690 | if (cmd) | 6700 | if (cmd) { |
6691 | pairing_complete(cmd, status); | 6701 | cmd->cmd_complete(cmd, status); |
6702 | mgmt_pending_remove(cmd); | ||
6703 | } | ||
6692 | } | 6704 | } |
6693 | 6705 | ||
6694 | void mgmt_auth_enable_complete(struct hci_dev *hdev, u8 status) | 6706 | void mgmt_auth_enable_complete(struct hci_dev *hdev, u8 status) |