p->subs[SUB_REAL].owner->bridge->name, p->subs[SUB_THREEWAY].owner->name);
return -1;
}
- /* Orphan the channel */
+ /* Orphan the channel after releasing the lock */
+ ast_mutex_unlock(&p->subs[SUB_THREEWAY].owner->lock);
unalloc_sub(p, SUB_THREEWAY);
} else if (p->subs[SUB_THREEWAY].owner->bridge) {
if (p->subs[SUB_REAL].owner->_state == AST_STATE_RINGING) {
return -1;
}
swap_subs(p, SUB_THREEWAY, SUB_REAL);
+ ast_mutex_unlock(&p->subs[SUB_THREEWAY].owner->lock);
unalloc_sub(p, SUB_THREEWAY);
/* Tell the caller not to hangup */
return 1;
}
} else
p->subs[SUB_THREEWAY].owner->_softhangup |= AST_SOFTHANGUP_DEV;
- ast_mutex_unlock(&p->subs[SUB_THREEWAY].owner->lock);
+ if (p->subs[SUB_THREEWAY].owner)
+ ast_mutex_unlock(&p->subs[SUB_THREEWAY].owner->lock);
} else {
ast_mutex_unlock(&p->subs[SUB_THREEWAY].owner->lock);
/* Swap subs and dis-own channel */