aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2015-10-22 03:49:39 -0400
committerMarcel Holtmann <marcel@holtmann.org>2015-10-22 05:37:22 -0400
commit88d07feb097b60fcca20ba63d2920b0f05a05fa0 (patch)
treee215b60c6877d32fa359bad105f23308ff91072e
parent89e0ccc882c47a4553698a580bec70cd90bc6319 (diff)
Bluetooth: Make hci_disconnect() behave correctly for all states
There are a few places that don't explicitly check the connection state before calling hci_disconnect(). To make this API do the right thing take advantage of the new hci_abort_conn() API and also make sure to only read the clock offset if we're really connected. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
-rw-r--r--net/bluetooth/hci_conn.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 665a52fa6c60..85b82f7adbd2 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -226,8 +226,6 @@ static void hci_acl_create_connection(struct hci_conn *conn)
226 226
227int hci_disconnect(struct hci_conn *conn, __u8 reason) 227int hci_disconnect(struct hci_conn *conn, __u8 reason)
228{ 228{
229 struct hci_cp_disconnect cp;
230
231 BT_DBG("hcon %p", conn); 229 BT_DBG("hcon %p", conn);
232 230
233 /* When we are master of an established connection and it enters 231 /* When we are master of an established connection and it enters
@@ -235,7 +233,8 @@ int hci_disconnect(struct hci_conn *conn, __u8 reason)
235 * current clock offset. Processing of the result is done 233 * current clock offset. Processing of the result is done
236 * within the event handling and hci_clock_offset_evt function. 234 * within the event handling and hci_clock_offset_evt function.
237 */ 235 */
238 if (conn->type == ACL_LINK && conn->role == HCI_ROLE_MASTER) { 236 if (conn->type == ACL_LINK && conn->role == HCI_ROLE_MASTER &&
237 (conn->state == BT_CONNECTED || conn->state == BT_CONFIG)) {
239 struct hci_dev *hdev = conn->hdev; 238 struct hci_dev *hdev = conn->hdev;
240 struct hci_cp_read_clock_offset clkoff_cp; 239 struct hci_cp_read_clock_offset clkoff_cp;
241 240
@@ -244,11 +243,7 @@ int hci_disconnect(struct hci_conn *conn, __u8 reason)
244 &clkoff_cp); 243 &clkoff_cp);
245 } 244 }
246 245
247 conn->state = BT_DISCONN; 246 return hci_abort_conn(conn, reason);
248
249 cp.handle = cpu_to_le16(conn->handle);
250 cp.reason = reason;
251 return hci_send_cmd(conn->hdev, HCI_OP_DISCONNECT, sizeof(cp), &cp);
252} 247}
253 248
254static void hci_add_sco(struct hci_conn *conn, __u16 handle) 249static void hci_add_sco(struct hci_conn *conn, __u16 handle)