diff --git a/apps/app_queue.c b/apps/app_queue.c
index dc1710fee99d7056c9ca07f77c56ea1a2f6d58c2..e5e48414929e55165cb0e3d67ea07791fd6af67d 100755
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -1370,8 +1370,8 @@ static int __queues_show(int fd, int argc, char **argv, int queue_show)
 		ast_mutex_lock(&q->lock);
 		if (queue_show) {
 			if (strcasecmp(q->name, argv[2]) != 0) {
-				q = q->next;
 				ast_mutex_unlock(&q->lock);
+				q = q->next;
 				if (!q) {
 					ast_cli(fd, "No such queue: %s.\n",argv[2]);
 					break;