From: Robin Murphy Date: Thu, 1 Oct 2015 22:37:19 +0000 (-0700) Subject: dmapool: fix overflow condition in pool_find_page() X-Git-Tag: v4.9.8~3464^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=676bd99178cd962ed24ffdad222b7069d330a969;p=platform%2Fkernel%2Flinux-rpi3.git dmapool: fix overflow condition in pool_find_page() If a DMA pool lies at the very top of the dma_addr_t range (as may happen with an IOMMU involved), the calculated end address of the pool wraps around to zero, and page lookup always fails. Tweak the relevant calculation to be overflow-proof. Signed-off-by: Robin Murphy Cc: Arnd Bergmann Cc: Marek Szyprowski Cc: Sumit Semwal Cc: Sakari Ailus Cc: Russell King Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/dmapool.c b/mm/dmapool.c index 71a8998..312a716 100644 --- a/mm/dmapool.c +++ b/mm/dmapool.c @@ -394,7 +394,7 @@ static struct dma_page *pool_find_page(struct dma_pool *pool, dma_addr_t dma) list_for_each_entry(page, &pool->page_list, page_list) { if (dma < page->dma) continue; - if (dma < (page->dma + pool->allocation)) + if ((dma - page->dma) < pool->allocation) return page; } return NULL;