Skip to contentSkip to conversation

Bluetooth: Fix cancel_delayed_work_sync usage with locks

PATCH Applied [email protected] 3 participants 3 messages Nov 8, 2011 – Nov 9, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Bluetooth: Fix cancel_delayed_work_sync usage with locks

From: Johan Hedberg <[email protected]>

The cancel_delayed_work_sync function should not be used if we hold any locks. Luckily all places where this is the case it is also safe to use the non-sync version.

---
 net/bluetooth/hci_core.c |    6 +++---
 net/bluetooth/mgmt.c     |    4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)
net/bluetooth/hci_core.c +3 -3
index f87bf24..fb3feeb 100644
@@ -599,12 +599,12 @@ static int hci_dev_do_close(struct hci_dev *hdev)
 	tasklet_kill(&hdev->tx_task);
 
 	if (hdev->discov_timeout > 0) {
-		cancel_delayed_work_sync(&hdev->discov_off);
+		cancel_delayed_work(&hdev->discov_off);
 		hdev->discov_timeout = 0;
 	}
 
 	if (test_and_clear_bit(HCI_AUTO_OFF, &hdev->flags))
-		cancel_delayed_work_sync(&hdev->power_off);
+		cancel_delayed_work(&hdev->power_off);
 
 	hci_dev_lock_bh(hdev);
 	inquiry_cache_flush(hdev);
@@ -828,7 +828,7 @@ int hci_get_dev_list(void __user *arg)
 	read_lock_bh(&hci_dev_list_lock);
 	list_for_each_entry(hdev, &hci_dev_list, list) {
 		if (test_and_clear_bit(HCI_AUTO_OFF, &hdev->flags))
-			cancel_delayed_work_sync(&hdev->power_off);
+			cancel_delayed_work(&hdev->power_off);
 
 		if (!test_bit(HCI_MGMT, &hdev->flags))
 			set_bit(HCI_PAIRABLE, &hdev->flags);
net/bluetooth/mgmt.c +2 -2
index be4c3d0..263fa27 100644
@@ -149,7 +149,7 @@ static int read_index_list(struct sock *sk)
 	i = 0;
 	list_for_each_entry(d, &hci_dev_list, list) {
 		if (test_and_clear_bit(HCI_AUTO_OFF, &d->flags))
-			cancel_delayed_work_sync(&d->power_off);
+			cancel_delayed_work(&d->power_off);
 
 		if (test_bit(HCI_SETUP, &d->flags))
 			continue;
@@ -398,7 +398,7 @@ static int set_discoverable(struct sock *sk, u16 index, unsigned char *data,
 	if (cp->val)
 		scan |= SCAN_INQUIRY;
 	else
-		cancel_delayed_work_sync(&hdev->discov_off);
+		cancel_delayed_work(&hdev->discov_off);
 
 	err = hci_send_cmd(hdev, HCI_OP_WRITE_SCAN_ENABLE, 1, &scan);
 	if (err < 0)
Signature · 1 line
1.7.7.1
maintainer Acked-by on v1 1/1
#1 lore raw

Hi Johan,

Quoted 9 lines

The cancel_delayed_work_sync function should not be used if we hold any locks. Luckily all places where this is the case it is also safe to use the non-sync version.

---
 net/bluetooth/hci_core.c |    6 +++---
 net/bluetooth/mgmt.c     |    4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

Regards

Marcel

#2 lore raw
In reply to [email protected]

Hi Johan,

Quoted 11 lines · * [email protected] <[email protected]> [2011-11-09 01:44:22 +0200]:

From: Johan Hedberg <[email protected]>

The cancel_delayed_work_sync function should not be used if we hold any locks. Luckily all places where this is the case it is also safe to use the non-sync version.

---
 net/bluetooth/hci_core.c |    6 +++---
 net/bluetooth/mgmt.c     |    4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

Applied, thanks.

Gustavo