audio: unref session when failed to setup
authorArchie Pusaka <apusaka@chromium.org>
Thu, 5 Nov 2020 06:40:33 +0000 (14:40 +0800)
committerAyush Garg <ayush.garg@samsung.com>
Fri, 11 Mar 2022 13:38:33 +0000 (19:08 +0530)
There is a possibility to miss unref-ing when source/sink fails at
setup.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
profiles/audio/sink.c
profiles/audio/source.c

index 6c6b7fe..d314ca9 100755 (executable)
@@ -268,8 +268,11 @@ gboolean sink_setup_stream(struct btd_service *service, struct avdtp *session)
 
        sink->connect_id = a2dp_discover(sink->session, discovery_complete,
                                                                sink);
-       if (sink->connect_id == 0)
+       if (sink->connect_id == 0) {
+               avdtp_unref(sink->session);
+               sink->session = NULL;
                return FALSE;
+       }
 
        return TRUE;
 }
index fca85d4..c706c92 100755 (executable)
@@ -259,8 +259,11 @@ gboolean source_setup_stream(struct btd_service *service,
 
        source->connect_id = a2dp_discover(source->session, discovery_complete,
                                                                source);
-       if (source->connect_id == 0)
+       if (source->connect_id == 0) {
+               avdtp_unref(source->session);
+               source->session = NULL;
                return FALSE;
+       }
 
        return TRUE;
 }