Skip to content

Commit

Permalink
dma_declare_coherent_memory wrong allocation
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Guennadi Liakhovetski authored and Linus Torvalds committed May 8, 2007
1 parent f19b121 commit b247e8a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion arch/cris/arch-v32/drivers/pci/dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion arch/i386/kernel/pci-dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit b247e8a

Please sign in to comment.