From: Russell Bryant Date: Wed, 17 Jan 2007 21:17:21 +0000 (+0000) Subject: Move the check for a failure of ast_channel_alloc() to before locking the X-Git-Tag: 1.2.15~48 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cbfeb816e15322b78c0713b88aa296f4fdcdb2aa;p=thirdparty%2Fasterisk.git Move the check for a failure of ast_channel_alloc() to before locking the pvt structure again. Otherwise, on a failure, this will cause a deadlock. git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@51197 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 8f4f0d1ec5..a316065f29 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -2782,11 +2782,11 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, char *title) ast_mutex_unlock(&i->lock); /* Don't hold a sip pvt lock while we allocate a channel */ tmp = ast_channel_alloc(1); - ast_mutex_lock(&i->lock); if (!tmp) { ast_log(LOG_WARNING, "Unable to allocate SIP channel structure\n"); return NULL; } + ast_mutex_lock(&i->lock); tmp->tech = &sip_tech; /* Select our native format based on codec preference until we receive something from another device to the contrary. */