Bluetooth: Pause service discovery for suspend
authorAbhishek Pandit-Subedi <abhishekpandit@chromium.org>
Thu, 17 Dec 2020 23:04:08 +0000 (15:04 -0800)
committerMarcel Holtmann <marcel@holtmann.org>
Fri, 18 Dec 2020 21:31:04 +0000 (22:31 +0100)
Just like MGMT_OP_START_DISCOVERY, we should reject
MGMT_OP_START_SERVICE_DISCOVERY with MGMT_STATUS_BUSY when we are paused
for suspend.

Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
net/bluetooth/mgmt.c

index fa0f7a4a1d2fc8a5422a1407bc63407f6ccdb338..608dda5403b7327cd2845eddb3eb57012f77726d 100644 (file)
@@ -4798,6 +4798,14 @@ static int start_service_discovery(struct sock *sk, struct hci_dev *hdev,
                goto failed;
        }
 
+       if (hdev->discovery_paused) {
+               err = mgmt_cmd_complete(sk, hdev->id,
+                                       MGMT_OP_START_SERVICE_DISCOVERY,
+                                       MGMT_STATUS_BUSY, &cp->type,
+                                       sizeof(cp->type));
+               goto failed;
+       }
+
        uuid_count = __le16_to_cpu(cp->uuid_count);
        if (uuid_count > max_uuid_count) {
                bt_dev_err(hdev, "service_discovery: too big uuid_count value %u",