aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/emulator
diff options
context:
space:
mode:
authorTedd Ho-Jeong An <tedd.an@intel.com>2021-06-25 23:30:09 -0700
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2021-07-01 14:26:01 -0700
commit77dba3b4d9b09fd9085b2945710ef46455c1842a (patch)
treec2d33be1a3d70ab2544961a1ce70b70722f74292 /emulator
parenta19b0d594b95ae49e1cfa99dfe874268119bf146 (diff)
emulator/btdev: clean up the queue before closing the test
This patch clean up the queue for connection before closing the test to prevent the potential memory leak. ==50== 32 bytes in 1 blocks are definitely lost in loss record 18 of 32 ==50== at 0x483A809: malloc (vg_replace_malloc.c:307) ==50== by 0x14A37E: btd_malloc (util.c:33) ==50== by 0x149D9D: queue_new (queue.c:47) ==50== by 0x13B3C0: btdev_create (btdev.c:6042) ==50== by 0x13178E: create_vhci (hciemu.c:229) ==50== by 0x13178E: hciemu_new_num (hciemu.c:403) ==50== by 0x130E2C: read_index_list_callback (mgmt-tester.c:357) ==50== by 0x14AD91: request_complete (mgmt.c:264) ==50== by 0x14BD34: can_read_data (mgmt.c:356) ==50== by 0x14E794: watch_callback (io-glib.c:157) ==50== by 0x48B578E: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.6400.6) ==50== by 0x48B5B17: ??? (in /usr/lib64/libglib-2.0.so.0.6400.6) ==50== by 0x48B5E32: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.6400.6) ==50== ==50== 32 bytes in 1 blocks are definitely lost in loss record 19 of 32 ==50== at 0x483A809: malloc (vg_replace_malloc.c:307) ==50== by 0x14A37E: btd_malloc (util.c:33) ==50== by 0x149D9D: queue_new (queue.c:47) ==50== by 0x13B3C0: btdev_create (btdev.c:6042) ==50== by 0x1318F7: hciemu_client_new (hciemu.c:332) ==50== by 0x1318F7: hciemu_new_num (hciemu.c:412) ==50== by 0x130E2C: read_index_list_callback (mgmt-tester.c:357) ==50== by 0x14AD91: request_complete (mgmt.c:264) ==50== by 0x14BD34: can_read_data (mgmt.c:356) ==50== by 0x14E794: watch_callback (io-glib.c:157) ==50== by 0x48B578E: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.6400.6) ==50== by 0x48B5B17: ??? (in /usr/lib64/libglib-2.0.so.0.6400.6) ==50== by 0x48B5E32: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.6400.6)
Diffstat (limited to 'emulator')
-rw-r--r--emulator/btdev.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/emulator/btdev.c b/emulator/btdev.c
index 90457a5aa2..a7fda2c896 100644
--- a/emulator/btdev.c
+++ b/emulator/btdev.c
@@ -624,8 +624,10 @@ static void conn_unlink(struct btdev_conn *conn1, struct btdev_conn *conn2)
conn2->link = NULL;
}
-static void conn_remove(struct btdev_conn *conn)
+static void conn_remove(void *data)
{
+ struct btdev_conn *conn = data;
+
if (conn->link) {
struct btdev_conn *link = conn->link;
@@ -6046,6 +6048,7 @@ void btdev_destroy(struct btdev *btdev)
bt_crypto_unref(btdev->crypto);
del_btdev(btdev);
+ queue_destroy(btdev->conns, conn_remove);
queue_destroy(btdev->le_ext_adv, le_ext_adv_free);
free(btdev);