It should always be considered that if send_request fails, sep should be removed from the list and the requested memory freed; --- profiles/audio/avdtp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c index 0d2213ea2..10ef380d4 100644 --- a/profiles/audio/avdtp.c +++ b/profiles/audio/avdtp.c @@ -2765,8 +2765,11 @@ static gboolean avdtp_discover_resp(struct avdtp *session, ret = send_request(session, TRUE, NULL, getcap_cmd, &req, sizeof(req)); - if (ret < 0) + if (ret < 0) { + session->seps = g_slist_remove(session->seps, sep); + g_free(sep); break; + } getcap_pending = TRUE; } -- 2.20.1