Skip to content
Snippets Groups Projects
Commit 4e56cc04 authored by Grzegorz Sluja's avatar Grzegorz Sluja Committed by Yalu Zhang
Browse files

Fix a crash in brcm_request() if it fails to create the ast_channel

In brcm_request() there were posibilities that we called ast_channel_name(tmp)
if tmp is NULL, it leads to crash. Also fixed other deadlock possibilities where
mutex would not be unlocked in some cases.
parent d6906ac0
No related branches found
No related tags found
1 merge request!67Fix crash in brcm_request() when ast_channel *tmp is NULL
...@@ -3443,20 +3443,20 @@ static struct ast_channel *brcm_request(const char *type, struct ast_format_cap ...@@ -3443,20 +3443,20 @@ static struct ast_channel *brcm_request(const char *type, struct ast_format_cap
if (!(ast_format_cap_has_type(cap, AST_MEDIA_TYPE_AUDIO))) { if (!(ast_format_cap_has_type(cap, AST_MEDIA_TYPE_AUDIO))) {
struct ast_str *codec_buf = ast_str_alloca(64); struct ast_str *codec_buf = ast_str_alloca(64);
ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format '%s'\n", ast_format_cap_get_names(cap, &codec_buf)); ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format '%s'\n", ast_format_cap_get_names(cap, &codec_buf));
return NULL;
} else if (sub) { } else if (sub) {
sub->channel_state = ALLOCATED; sub->channel_state = ALLOCATED;
sub->connection_id = ast_atomic_fetchadd_int((int *)&current_connection_id, +1); sub->connection_id = ast_atomic_fetchadd_int((int *)&current_connection_id, +1);
tmp = brcm_new(sub, AST_STATE_DOWN, sub->parent->ext, sub->parent->context, assignedids, requestor ? requestor : NULL, cap); tmp = brcm_new(sub, AST_STATE_DOWN, sub->parent->ext, sub->parent->context, assignedids, requestor ? requestor : NULL, cap);
} else { } else {
*cause = AST_CAUSE_BUSY; *cause = AST_CAUSE_BUSY;
ast_log(LOG_NOTICE, "Idle subchannel not found\n");
} }
//ast_mutex_unlock(&p->lock);
pvt_unlock(p); pvt_unlock(p);
ast_mutex_unlock(&iflock); ast_mutex_unlock(&iflock);
ast_debug(3, "Created a new ast_channel %s, uniqid:%s, linkedid:%s\n", ast_channel_name(tmp), ast_channel_uniqueid(tmp), if (tmp)
ast_debug(3, "Created a new ast_channel %s, uniqid:%s, linkedid:%s\n", ast_channel_name(tmp), ast_channel_uniqueid(tmp),
ast_channel_linkedid(tmp)); ast_channel_linkedid(tmp));
return tmp; return tmp;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment