Re: [PATCH] dma: fix up broken comparison indma_alloc_from_coherent

From: Adrian McMenamin
Date: Tue Jan 20 2009 - 16:56:36 EST

On Tue, 2009-01-20 at 21:48 +0000, Adrian McMenamin wrote:
> Currently this code compares a size in bytes with a size in pages.
> This patch makes both sides of the comparison bytes.

Apologies, here it is without the line wrap.

Currently this comparison is made between bytes and pages. This patch
ensures it is bytes on both side of the comparison.

Signed-off-by: Adrian McMenamin <adrian@xxxxxxxxxxxxxxxxx>

--- a/kernel/dma-coherent.c
+++ b/kernel/dma-coherent.c
@@ -118,7 +118,7 @@ int dma_alloc_from_coherent(struct device *dev, ssize_t size,
mem = dev->dma_mem;
if (!mem)
return 0;
- if (unlikely(size > mem->size))
+ if (unlikely(size > mem->size << PAGE_SHIFT))
return 0;

pageno = bitmap_find_free_region(mem->bitmap, mem->size, order);

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at