From 2087affd75f23d34b332ebd4d2da151b0951bf54 Mon Sep 17 00:00:00 2001
From: Patrick Tjin <pattjin@google.com>
Date: Tue, 6 Oct 2015 09:59:21 -0700
Subject: [PATCH] android: binder: move preempt disable after mmput

Don't disable preemption until after mmput since
mmput might sleep.

Bug: 24452701

Signed-off-by: Patrick Tjin <pattjin@google.com>
---
 drivers/staging/android/binder.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/android/binder.c b/drivers/staging/android/binder.c
index f318171bdbcb..2f287d072c4e 100644
--- a/drivers/staging/android/binder.c
+++ b/drivers/staging/android/binder.c
@@ -671,11 +671,13 @@ static int binder_update_page_range(struct binder_proc *proc, int allocate,
 		}
 		/* vm_insert_page does not seem to increment the refcount */
 	}
-	preempt_disable();
 	if (mm) {
 		up_write(&mm->mmap_sem);
 		mmput(mm);
 	}
+
+	preempt_disable();
+
 	return 0;
 
 free_range:
@@ -694,11 +696,13 @@ err_alloc_page_failed:
 		;
 	}
 err_no_vma:
-	preempt_disable();
 	if (mm) {
 		up_write(&mm->mmap_sem);
 		mmput(mm);
 	}
+
+	preempt_disable();
+
 	return -ENOMEM;
 }
 
-- 
GitLab