From 1ab8cca11072744f46654f66bf40e2b0a8e41c26 Mon Sep 17 00:00:00 2001
From: Walter Doekes <walter+asterisk@wjd.nu>
Date: Wed, 28 May 2014 09:41:53 +0000
Subject: [PATCH] chan_unistim: Unlock mutex in rare OOM condition.

ASTERISK-23792 #close
Reported by: Peter Whisker

Review: https://reviewboard.asterisk.org/r/3567/


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/11@414677 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 channels/chan_unistim.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/channels/chan_unistim.c b/channels/chan_unistim.c
index 66d282b382..e13cc97058 100644
--- a/channels/chan_unistim.c
+++ b/channels/chan_unistim.c
@@ -6276,10 +6276,10 @@ static struct unistim_device *build_device(const char *cat, const struct ast_var
 		}
 		d = d->next;
 	}
+	ast_mutex_unlock(&devicelock);
 	if (!(lt = ast_calloc(1, sizeof(*lt)))) {
 		return NULL;
 	}
-	ast_mutex_unlock(&devicelock);
 	if (create) {
 		if (!(d = ast_calloc(1, sizeof(*d)))) {
 			return NULL;
-- 
GitLab