Commit ea05c8444e451f1cfbf78c68733e717ad7b8602b

Authored by Dima Zavin
Committed by Linus Torvalds
1 parent d65bfacb04

mm: add a might_sleep_if() to dma_pool_alloc()

Buggy drivers (e.g.  fsl_udc) could call dma_pool_alloc from atomic
context with GFP_KERNEL.  In most instances, the first pool_alloc_page
call would succeed and the sleeping functions would never be called.  This
allowed the buggy drivers to slip through the cracks.

Add a might_sleep_if() checking for __GFP_WAIT in flags.

Signed-off-by: Dima Zavin <dima@android.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 2 additions and 0 deletions Side-by-side Diff

... ... @@ -311,6 +311,8 @@
311 311 size_t offset;
312 312 void *retval;
313 313  
  314 + might_sleep_if(mem_flags & __GFP_WAIT);
  315 +
314 316 spin_lock_irqsave(&pool->lock, flags);
315 317 restart:
316 318 list_for_each_entry(page, &pool->page_list, page_list) {