You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by "MariuszSkamra (via GitHub)" <gi...@apache.org> on 2024/02/19 14:06:11 UTC

[PR] nimble/iso: Fix couple of ISO related issues [mynewt-nimble]

MariuszSkamra opened a new pull request, #1700:
URL: https://github.com/apache/mynewt-nimble/pull/1700

   This fixes BIG handle assignment from dedicated pool of handles, missing BIG instance pointer checks and missing BIG related HCI events in the LE event mask.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] nimble/iso: Fix couple of ISO related issues found [mynewt-nimble]

Posted by "rymanluk (via GitHub)" <gi...@apache.org>.
rymanluk merged PR #1700:
URL: https://github.com/apache/mynewt-nimble/pull/1700


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] nimble/iso: Fix couple of ISO related issues found [mynewt-nimble]

Posted by "MariuszSkamra (via GitHub)" <gi...@apache.org>.
MariuszSkamra commented on code in PR #1700:
URL: https://github.com/apache/mynewt-nimble/pull/1700#discussion_r1494630669


##########
nimble/host/src/ble_iso.c:
##########
@@ -47,57 +47,71 @@ static struct os_mempool ble_iso_big_pool;
 static os_membuf_t ble_iso_big_mem[
     OS_MEMPOOL_SIZE(MYNEWT_VAL(BLE_MAX_BIG), sizeof (struct ble_iso_big))];
 
-static struct ble_iso_big *
-ble_iso_big_alloc(uint8_t adv_handle)
+static int
+ble_iso_big_handle_set(struct ble_iso_big *big)
 {
-    struct ble_iso_big *new_big;
-    struct ble_iso_big *big;
+    static uint8_t free_handle;
+    uint8_t i;
 
-    if (adv_handle >= BLE_ADV_INSTANCES) {
-        BLE_HS_LOG_ERROR("Invalid advertising instance");
-        return NULL;
-    }
+    big->handle = free_handle;
 
-    if (!ble_gap_ext_adv_active(adv_handle)) {
-        BLE_HS_LOG_ERROR("Instance not active");
-        return NULL;
+    /* Set next free handle */
+    for (i = BLE_HCI_ISO_BIG_HANDLE_MIN; i < BLE_HCI_ISO_BIG_HANDLE_MAX; i++) {
+        struct ble_iso_big *node = NULL;
+
+        free_handle++;
+        if (free_handle > BLE_HCI_ISO_BIG_HANDLE_MAX) {
+            free_handle = BLE_HCI_ISO_BIG_HANDLE_MIN;
+        }
+
+        SLIST_FOREACH(node, &ble_iso_bigs, next) {
+            if (node->handle == free_handle) {
+                break;
+            }
+        }
+
+        if (node == NULL || node->handle != free_handle) {
+            return 0;
+        }
     }
 
+    BLE_HS_DBG_ASSERT(0);
+
+    return BLE_HS_EOS;
+}
+
+static struct ble_iso_big *
+ble_iso_big_alloc(void)
+{
+    struct ble_iso_big *new_big;
+    int rc;
+
     new_big = os_memblock_get(&ble_iso_big_pool);
     if (new_big == NULL) {
-        BLE_HS_LOG_ERROR("No more memory in pool");
+        BLE_HS_LOG_ERROR("No more memory in pool\n");
         /* Out of memory. */
         return NULL;
     }
 
     memset(new_big, 0, sizeof *new_big);
 
-    SLIST_FOREACH(big, &ble_iso_bigs, next) {
-        if (big->id == adv_handle) {
-            BLE_HS_LOG_ERROR("Advertising instance (%d) already in use",
-                             adv_handle);
-            return NULL;
-        }
+    rc = ble_iso_big_handle_set(new_big);
+    if (rc != 0) {
+        return NULL;
     }

Review Comment:
   Potential memory leak. Missing `os_memblock_put`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org