Skip to contentSkip to conversation

usb: bluetooth: get lock before calling usb_[disable|enable]_autosuspend()

PATCH In review Salah Triki 2 participants 2 messages Aug 2, 2021 – Aug 3, 2021 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: bluetooth: get lock before calling usb_[disable|enable]_autosuspend()

Based on the documentation of usb_[disable|enable]_autosuspend(), the caller must hold udev's device lock.

---
 drivers/bluetooth/btusb.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/bluetooth/btusb.c +4 -1
index a9855a2dd561..2ceb48164b6d 100644
@@ -1939,8 +1939,11 @@ static int btusb_setup_csr(struct hci_dev *hdev)
 
 			device_set_wakeup_capable(&data->udev->dev, false);
 			/* Re-enable autosuspend if this was requested */
-			if (enable_autosuspend)
+			if (enable_autosuspend) {
+				usb_lock_device(data->udev);
 				usb_enable_autosuspend(data->udev);
+				usb_unlock_device(data->udev);
+			}
 		}
 	}
 
Signature · 1 line
2.25.1
#1 lore raw
Quoted 28 lines · Salah Triki

Based on the documentation of usb_[disable|enable]_autosuspend(), the caller must hold udev's device lock.

---
 drivers/bluetooth/btusb.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/bluetooth/btusb.c +4 -1
index a9855a2dd561..2ceb48164b6d 100644
@@ -1939,8 +1939,11 @@ static int btusb_setup_csr(struct hci_dev *hdev)
 
 			device_set_wakeup_capable(&data->udev->dev, false);
 			/* Re-enable autosuspend if this was requested */
-			if (enable_autosuspend)
+			if (enable_autosuspend) {
+				usb_lock_device(data->udev);
 				usb_enable_autosuspend(data->udev);
+				usb_unlock_device(data->udev);
+			}
 		}
 	}
 
Signature · 1 line
2.25.1

As was pointed out elsewhere, this is not correct.

thanks,

greg k-h