From 1c1f006be0b129d73d98f87c2b1455ea4080fa7a Mon Sep 17 00:00:00 2001
From: Roman Kiryanov <rkir@google.com>
Date: Tue, 11 Sep 2018 16:30:15 -0700
Subject: [PATCH] Add missing mutex_unlock if pin_user_pages fails

Bug: 111742629
Test: built kernel
Change-Id: I358b3e487bc4e276d7f91afe7761a7014368a237
Signed-off-by: Roman Kiryanov <rkir@google.com>
---
 drivers/platform/goldfish/goldfish_pipe_v2.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/goldfish/goldfish_pipe_v2.c b/drivers/platform/goldfish/goldfish_pipe_v2.c
index dd362d637611..bd4ed577a245 100644
--- a/drivers/platform/goldfish/goldfish_pipe_v2.c
+++ b/drivers/platform/goldfish/goldfish_pipe_v2.c
@@ -391,8 +391,10 @@ static int transfer_max_buffers(struct goldfish_pipe *pipe,
 	pages_count = pin_user_pages(first_page, last_page,
 				     last_page_size, is_write,
 				     pipe->pages, &iter_last_page_size);
-	if (pages_count < 0)
+	if (pages_count < 0) {
+		mutex_unlock(&pipe->lock);
 		return pages_count;
+	}
 
 	populate_rw_params(pipe->pages, pages_count, address, address_end,
 			   first_page, last_page, iter_last_page_size, is_write,
-- 
GitLab