@@ -258,8 +258,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;
}
@@ -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;
}