adapter: Fix adding SDP records when operating on LE only mode
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Thu, 24 Mar 2022 21:24:12 +0000 (14:24 -0700)
committerAyush Garg <ayush.garg@samsung.com>
Mon, 15 May 2023 09:25:53 +0000 (14:55 +0530)
If mode is set to BT_MODE_LE SDP protocol won't be operational so it is
useless to attempt to add records.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
src/adapter.c

index 7123028..9bf6af2 100644 (file)
@@ -1680,6 +1680,13 @@ int adapter_service_add(struct btd_adapter *adapter, sdp_record_t *rec)
 {
        int ret;
 
+       /*
+        * If the controller does not support BR/EDR operation,
+        * there is no point in trying to add SDP records.
+        */
+       if (btd_opts.mode == BT_MODE_LE)
+               return -ENOTSUP;
+
        DBG("%s", adapter->path);
 
        ret = add_record_to_server(&adapter->bdaddr, rec);
@@ -1693,10 +1700,17 @@ int adapter_service_add(struct btd_adapter *adapter, sdp_record_t *rec)
 
 void adapter_service_remove(struct btd_adapter *adapter, uint32_t handle)
 {
-       sdp_record_t *rec = sdp_record_find(handle);
+       sdp_record_t *rec;
+       /*
+        * If the controller does not support BR/EDR operation,
+        * there is no point in trying to remote SDP records.
+        */
+       if (btd_opts.mode == BT_MODE_LE)
+               return;
 
        DBG("%s", adapter->path);
 
+       rec = sdp_record_find(handle);
        if (!rec)
                return;