Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH v3 1/3] Bluetooth: Move discovery state check inside hci_dev_lock()
@ 2013-01-15 13:01 Jaganath Kanakkassery
  2013-01-15 13:01 ` [PATCH v3 2/3] Bluetooth: Add mgmt_start_discovery_cancelled() Jaganath Kanakkassery
  2013-01-15 13:01 ` [PATCH v3 3/3] Bluetooth: Fix stop discovery while in STARTING state Jaganath Kanakkassery
  0 siblings, 2 replies; 5+ messages in thread
From: Jaganath Kanakkassery @ 2013-01-15 13:01 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jaganath Kanakkassery

After checking the discovery state, if other thread modifies it
then it will be overwritten by the assignment in the first thread.

Signed-off-by: Jaganath Kanakkassery <jaganath.k@samsung.com>
---
 net/bluetooth/hci_event.c |    9 ++++-----
 net/bluetooth/mgmt.c      |    4 ----
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 705078a..97b4828 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1273,14 +1273,13 @@ static void hci_cc_le_set_scan_enable(struct hci_dev *hdev,
 
 		clear_bit(HCI_LE_SCAN, &hdev->dev_flags);
 
+		hci_dev_lock(hdev);
 		if (hdev->discovery.type == DISCOV_TYPE_INTERLEAVED &&
-		    hdev->discovery.state == DISCOVERY_FINDING) {
+		    hdev->discovery.state == DISCOVERY_FINDING)
 			mgmt_interleaved_discovery(hdev);
-		} else {
-			hci_dev_lock(hdev);
+		else
 			hci_discovery_set_state(hdev, DISCOVERY_STOPPED);
-			hci_dev_unlock(hdev);
-		}
+		hci_dev_unlock(hdev);
 
 		break;
 
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index e5502a5..bcc7080 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -2298,14 +2298,10 @@ int mgmt_interleaved_discovery(struct hci_dev *hdev)
 
 	BT_DBG("%s", hdev->name);
 
-	hci_dev_lock(hdev);
-
 	err = hci_do_inquiry(hdev, INQUIRY_LEN_BREDR_LE);
 	if (err < 0)
 		hci_discovery_set_state(hdev, DISCOVERY_STOPPED);
 
-	hci_dev_unlock(hdev);
-
 	return err;
 }
 
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-01-16  6:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-15 13:01 [PATCH v3 1/3] Bluetooth: Move discovery state check inside hci_dev_lock() Jaganath Kanakkassery
2013-01-15 13:01 ` [PATCH v3 2/3] Bluetooth: Add mgmt_start_discovery_cancelled() Jaganath Kanakkassery
2013-01-15 13:01 ` [PATCH v3 3/3] Bluetooth: Fix stop discovery while in STARTING state Jaganath Kanakkassery
2013-01-15 16:17   ` Marcel Holtmann
2013-01-16  6:03     ` Jaganath Kanakkassery

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox