]> granicus.if.org Git - esp-idf/commitdiff
Component/bt: fix memory leak in SMP
authorzhiweijian <zhiweijian@espressif.com>
Tue, 19 Dec 2017 07:00:01 +0000 (15:00 +0800)
committerzhiweijian <zhiweijian@espressif.com>
Wed, 20 Dec 2017 02:30:31 +0000 (10:30 +0800)
components/bt/bluedroid/btc/core/btc_dm.c
components/bt/bluedroid/osi/config.c
components/bt/bluedroid/stack/btm/btm_sec.c

index b81d5bc7b66d7dd1e93db960064aeea231c15052..6ec2b004fb868a6e2d458a04a3b86c8ad6c3b12b 100644 (file)
@@ -247,12 +247,6 @@ static void btc_dm_ble_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
          if (btc_storage_get_remote_addr_type(&bdaddr, &addr_type) != BT_STATUS_SUCCESS) {
             btc_storage_set_remote_addr_type(&bdaddr, p_auth_cmpl->addr_type, true);
         }
-        /* check the irk has been save in the flash or not, if the irk has already save, means that the peer device has bonding
-           before. */
-        if(pairing_cb.ble.is_pid_key_rcvd) {
-            btc_storage_compare_address_key_value(&bdaddr, BTM_LE_KEY_PID,
-                                                  (void *)&pairing_cb.ble.pid_key, sizeof(tBTM_LE_PID_KEYS));
-        }
         btc_dm_save_ble_bonding_keys();
     } else {
         /*Map the HCI fail reason  to  bt status  */
index 590e0392b70302d051c7b51ce5bed8e48f477655..f6f9a6587ba4dd1ce2b546221aa2b8aa55cc65d5 100644 (file)
@@ -436,6 +436,9 @@ static void config_parse(nvs_handle fp, config_t *config)
     esp_err_t err;
     size_t length = CONFIG_FILE_MAX_SIZE;
     err = nvs_get_blob(fp, CONFIG_KEY, buf, &length);
+    if (err == ESP_ERR_NVS_NOT_FOUND) {
+        goto error;
+    }
     if (err != ESP_OK) {
         err_code |= 0x02;
         goto error;
index 146c10c860ffbe7d492ec7137c1c6a1b0148c64d..bc591ad7240c58deec9dbb5c81e59c4b612a2a56 100644 (file)
@@ -2762,8 +2762,9 @@ void btm_sec_check_pending_reqs (void)
 
         /* Now, re-submit anything in the mux queue */
         bq = btm_cb.sec_pending_q;
-
-        btm_cb.sec_pending_q = fixed_queue_new(SIZE_MAX);
+        if (!btm_cb.sec_pending_q) {
+            btm_cb.sec_pending_q = fixed_queue_new(SIZE_MAX);
+        }
 
         while ((p_e = (tBTM_SEC_QUEUE_ENTRY *)fixed_queue_try_dequeue(bq)) != NULL) {
             /* Check that the ACL is still up before starting security procedures */