From 32ba935d89d41d0bc6bd4264a6f16d66ccbd126e Mon Sep 17 00:00:00 2001 From: Srinivas Krovvidi Date: Thu, 26 Jan 2012 10:48:08 +0530 Subject: [PATCH] Bluetooth: Avoid link entering sniff mode during pairing process. Found incoming connection issue with IOT devices when link enters sniff mode during pairing process. The current change avoids link entering sniff mode when link key is not available for connection. Change-Id: I26fbbccec8d7b3faa91cba8f976fb0e44d7f5344 CRs-Fixed: 331520 Signed-off-by: Srinivas Krovvidi --- net/bluetooth/hci_conn.c | 4 +++- net/bluetooth/hci_event.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index ccf362376f0..f0f2ac1508a 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -909,7 +909,9 @@ void hci_conn_enter_sniff_mode(struct hci_conn *conn) if (!lmp_sniff_capable(hdev) || !lmp_sniff_capable(conn)) return; - if (conn->mode != HCI_CM_ACTIVE || !(conn->link_policy & HCI_LP_SNIFF)) + if (conn->mode != HCI_CM_ACTIVE || + !(conn->link_policy & HCI_LP_SNIFF) || + (hci_find_link_key(hdev, &conn->dst) == NULL)) return; if (lmp_sniffsubr_capable(hdev) && lmp_sniffsubr_capable(conn)) { diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 675b34f52a4..fec6f32c426 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -1,6 +1,6 @@ /* BlueZ - Bluetooth protocol stack for Linux - Copyright (c) 2000-2001, 2010-2011, Code Aurora Forum. All rights reserved. + Copyright (c) 2000-2001, 2010-2012, Code Aurora Forum. All rights reserved. Written 2000,2001 by Maxim Krasnyansky @@ -2492,6 +2492,7 @@ static inline void hci_pin_code_request_evt(struct hci_dev *hdev, struct sk_buff hci_conn_hold(conn); conn->disc_timeout = HCI_PAIRING_TIMEOUT; hci_conn_put(conn); + hci_conn_enter_active_mode(conn, 0); } if (!test_bit(HCI_PAIRABLE, &hdev->flags)) @@ -2587,6 +2588,7 @@ static inline void hci_link_key_notify_evt(struct hci_dev *hdev, struct sk_buff pin_len = conn->pin_length; hci_conn_put(conn); + hci_conn_enter_active_mode(conn, 0); } if (test_bit(HCI_LINK_KEYS, &hdev->flags))