]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
dma_declare_coherent_memory wrong allocation
authorGuennadi Liakhovetski <g.liakhovetski@gmx.de>
Tue, 8 May 2007 07:31:25 +0000 (00:31 -0700)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Tue, 8 May 2007 18:15:14 +0000 (11:15 -0700)
dma_declare_coherent_memory() allocates a bitmap 1 bit per page, it
calculates the bitmap size based on size of long, but allocates bytes...
Thanks to James Bottomley for clarifications and corrections.

Signed-off-by: G. Liakhovetski <g.liakhovetski@gmx.de>
Acked-by: James Bottomley <James.Bottomley@SteelEye.com>
Cc: Mikael Starvik <starvik@axis.com>
Cc: Andi Kleen <ak@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
arch/cris/arch-v32/drivers/pci/dma.c
arch/i386/kernel/pci-dma.c

index 70d3bf0c92e8ebdda3c5d56bcb3663cfe6dc7ffc..832fc63504d4decd21c03eb4ba8fb7462a406851 100644 (file)
@@ -76,7 +76,7 @@ int dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
 {
        void __iomem *mem_base;
        int pages = size >> PAGE_SHIFT;
-       int bitmap_size = (pages + 31)/32;
+       int bitmap_size = BITS_TO_LONGS(pages) * sizeof(long);
 
        if ((flags & (DMA_MEMORY_MAP | DMA_MEMORY_IO)) == 0)
                goto out;
index 3ebcea033623e357904d52195d4d52d526267636..30b754f7cbec2d827ac07b8475bb499d35257811 100644 (file)
@@ -77,7 +77,7 @@ int dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
 {
        void __iomem *mem_base = NULL;
        int pages = size >> PAGE_SHIFT;
-       int bitmap_size = (pages + 31)/32;
+       int bitmap_size = BITS_TO_LONGS(pages) * sizeof(long);
 
        if ((flags & (DMA_MEMORY_MAP | DMA_MEMORY_IO)) == 0)
                goto out;