linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: add a might_sleep_if in dma_pool_alloc
@ 2010-09-23  3:52 Dima Zavin
  0 siblings, 0 replies; only message in thread
From: Dima Zavin @ 2010-09-23  3:52 UTC (permalink / raw)
  To: linux-kernel; +Cc: linux-mm, Dima Zavin

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>
---
 mm/dmapool.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/mm/dmapool.c b/mm/dmapool.c
index 3df0637..4df2de7 100644
--- a/mm/dmapool.c
+++ b/mm/dmapool.c
@@ -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) {
-- 
1.6.6

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2010-09-23  3:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-23  3:52 [PATCH] mm: add a might_sleep_if in dma_pool_alloc Dima Zavin

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).