From: Tedd Ho-Jeong An <hj.tedd.an@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [RFC BlueZ PATCH v4 2/3] emulator/btdev: clean up the queue before closing the test
Date: Fri, 25 Jun 2021 23:30:09 -0700 [thread overview]
Message-ID: <20210626063010.152987-2-hj.tedd.an@gmail.com> (raw)
In-Reply-To: <20210626063010.152987-1-hj.tedd.an@gmail.com>
From: Tedd Ho-Jeong An <tedd.an@intel.com>
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)
---
emulator/btdev.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/emulator/btdev.c b/emulator/btdev.c
index 202fc7996..75cca7549 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;
@@ -6056,6 +6058,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);
--
2.26.3
next prev parent reply other threads:[~2021-06-26 6:30 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-26 6:30 [RFC BlueZ PATCH v4 1/3] emulator/btdev: Update the white list and resolving list size Tedd Ho-Jeong An
2021-06-26 6:30 ` Tedd Ho-Jeong An [this message]
2021-07-01 21:28 ` [RFC BlueZ PATCH v4 2/3] emulator/btdev: clean up the queue before closing the test Luiz Augusto von Dentz
2021-06-26 6:30 ` [RFC BlueZ PATCH v4 3/3] tools/mgmt-tester: Add LL Privacy test cases Tedd Ho-Jeong An
2021-06-26 7:08 ` [RFC,BlueZ,v4,1/3] emulator/btdev: Update the white list and resolving list size bluez.test.bot
2021-07-01 21:43 ` [RFC BlueZ PATCH v4 1/3] " Luiz Augusto von Dentz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210626063010.152987-2-hj.tedd.an@gmail.com \
--to=hj.tedd.an@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).