Skip to content

Commit

Permalink
ashmem: Fix ashmem_shrink deadlock.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Robert Love authored and hellsgod committed Sep 11, 2013
1 parent 5521295 commit 7b4b008
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion drivers/staging/android/ashmem.c
Expand Up @@ -365,7 +365,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) {
struct inode *inode = range->asma->file->f_dentry->d_inode;
loff_t start = range->pgstart * PAGE_SIZE;
Expand Down

0 comments on commit 7b4b008

Please sign in to comment.