linux-next.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] ashmem: Fix ashmem_shrink deadlock.
@ 2013-05-01 13:56 Robert Love
  2013-05-01 15:54 ` David Rientjes
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Robert Love @ 2013-05-01 13:56 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Shankar Brahadeeswaran, Dan Carpenter, LKML,
	Bjorn Bringert, devel, Hugh Dickins, Anjana V Kumar, Dad,
	linux-next

Don't acquire ashmem_mutex in ashmem_shrink if we've somehow recursed into the
shrinker code from within ashmem. Just bail out, avoiding a deadlock. This is
fine, as ashmem cache pruning is advisory anyhow.

Signed-off-by: Robert Love <rlove@google.com>
---
 drivers/staging/android/ashmem.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c
index e681bdd..82c6768 100644
--- a/drivers/staging/android/ashmem.c
+++ b/drivers/staging/android/ashmem.c
@@ -363,7 +363,11 @@ static int ashmem_shrink(struct shrinker *s, struct shrink_control *sc)
 	if (!sc->nr_to_scan)
 		return lru_count;
 
-	mutex_lock(&ashmem_mutex);
+	/* avoid recursing into this code from within ashmem itself */
+	if (!mutex_trylock(&ashmem_mutex)) {
+		return -1;
+	}
+
 	list_for_each_entry_safe(range, next, &ashmem_lru_list, lru) {
 		loff_t start = range->pgstart * PAGE_SIZE;
 		loff_t end = (range->pgend + 1) * PAGE_SIZE;
-- 
1.8.2.1

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2013-09-17  5:05 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-01 13:56 [PATCH -next] ashmem: Fix ashmem_shrink deadlock Robert Love
2013-05-01 15:54 ` David Rientjes
2013-05-02 18:22   ` David Rientjes
2013-05-02 20:39     ` Greg Kroah-Hartman
2013-05-07 20:52 ` Andrew Morton
2013-05-13 21:42 ` Greg Kroah-Hartman
2013-05-14  3:29   ` Neil Zhang
2013-05-14  3:37     ` Raul Xiong
2013-05-16  8:15       ` Raul Xiong
2013-05-16 13:44         ` Robert Love
2013-05-16 16:45           ` Andrew Morton
2013-05-16 17:08             ` Robert Love
2013-05-16 17:19               ` Andrew Morton
2013-05-16 17:28                 ` Robert Love
2013-09-17  5:05                   ` Raul Xiong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).