diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index 5b17fa4647ee90f53b79ae712124045ff5bdf2c4..404f32ad7deee5ec26594efb543b92670cc0e7ca 100755
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -4948,11 +4948,21 @@ retryowner:
 						iaxs[fr.callno]->owner->nativeformats = iaxs[fr.callno]->peerformat;
 						if (option_verbose > 2)
 							ast_verbose(VERBOSE_PREFIX_3 "Format for call is %s\n", ast_getformatname(iaxs[fr.callno]->owner->nativeformats));
-						/* Setup read/write formats properly. */
-						if (iaxs[fr.callno]->owner->writeformat)
-							ast_set_write_format(iaxs[fr.callno]->owner, iaxs[fr.callno]->owner->writeformat);	
-						if (iaxs[fr.callno]->owner->readformat)
-							ast_set_read_format(iaxs[fr.callno]->owner, iaxs[fr.callno]->owner->readformat);	
+retryowner2:
+						if (ast_mutex_trylock(&iaxs[fr.callno]->owner->lock)) {
+							ast_mutex_unlock(&iaxsl[fr.callno]);
+							usleep(1);
+							ast_mutex_lock(&iaxsl[fr.callno]);
+							if (iaxs[fr.callno] && iaxs[fr.callno]->owner) goto retryowner2;
+						}
+						
+						if (iaxs[fr.callno] && iaxs[fr.callno]->owner) {
+							/* Setup read/write formats properly. */
+							if (iaxs[fr.callno]->owner->writeformat)
+								ast_set_write_format(iaxs[fr.callno]->owner, iaxs[fr.callno]->owner->writeformat);	
+							if (iaxs[fr.callno]->owner->readformat)
+								ast_set_read_format(iaxs[fr.callno]->owner, iaxs[fr.callno]->owner->readformat);	
+						}
 					}
 				}
 				ast_mutex_lock(&dpcache_lock);