Skip to content

Commit

Permalink
mm: add a might_sleep_if() to dma_pool_alloc()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Dima Zavin authored and torvalds committed Oct 26, 2010
1 parent d65bfac commit ea05c84
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions mm/dmapool.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,8 @@ void *dma_pool_alloc(struct dma_pool *pool, gfp_t mem_flags,
size_t offset;
void *retval;

might_sleep_if(mem_flags & __GFP_WAIT);

spin_lock_irqsave(&pool->lock, flags);
restart:
list_for_each_entry(page, &pool->page_list, page_list) {
Expand Down

0 comments on commit ea05c84

Please sign in to comment.