diff --git a/profiles/audio/a2dp.c b/profiles/audio/a2dp.c
index efb4178..4b28465 100644
--- a/profiles/audio/a2dp.c
+++ b/profiles/audio/a2dp.c
static gboolean auto_config(gpointer data)
{
struct a2dp_setup *setup = data;
- struct avdtp_error *err = NULL;
/* Check if configuration was aborted */
if (setup->sep->stream == NULL)
return FALSE;
- if (setup->err != NULL) {
- err = setup->err;
+ if (setup->err != NULL)
goto done;
- }
avdtp_stream_add_cb(setup->session, setup->stream,
stream_state_changed, setup->sep);
finalize_config(setup);
- if (err)
- g_free(err);
+ if (setup->err) {
+ g_free(setup->err);
+ setup->err = NULL;
+ }
setup_unref(setup);
if (setup) {
setup->err = err;
finalize_config(setup);
+ setup->err = NULL;
}
return;
}