avdtp: fix possible minor problems
authorlishengyu <lishengyu@uniontech.com>
Wed, 29 Jun 2022 12:46:56 +0000 (20:46 +0800)
committerAyush Garg <ayush.garg@samsung.com>
Mon, 15 May 2023 09:25:54 +0000 (14:55 +0530)
It should always be considered that if send_request fails, sep
should be removed from the list and the requested memory freed;

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
profiles/audio/avdtp.c

index 53c85a5..2ce4f47 100644 (file)
@@ -3293,8 +3293,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;
        }