The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] dma_declare_coherent_memory wrong allocation
@ 2007-04-13 18:08 Guennadi Liakhovetski
  2007-04-21  7:08 ` Andrew Morton
  2007-04-22 16:52 ` James Bottomley
  0 siblings, 2 replies; 9+ messages in thread
From: Guennadi Liakhovetski @ 2007-04-13 18:08 UTC (permalink / raw)
  To: James Bottomley; +Cc: linux-kernel

Hi

Either I've finally gone blind on this Friday 13th or... Looks like this 
almost 3 year old function has a bug. Patch below compile-tested... in a 
way.

Thanks
Guennadi
---
Guennadi Liakhovetski

dma_declare_coherent_memory() allocates a bitmap 1 bit per page, it 
calculates the bitmap size based on size of long, but allocates bytes...

Signed-off-by: G. Liakhovetski <g.liakhovetski@gmx.de>

diff --git a/arch/i386/kernel/pci-dma.c b/arch/i386/kernel/pci-dma.c
index 3ebcea0..3d55226 100644
--- a/arch/i386/kernel/pci-dma.c
+++ b/arch/i386/kernel/pci-dma.c
@@ -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 = DIV_ROUND_UP(pages, 8);
 
 	if ((flags & (DMA_MEMORY_MAP | DMA_MEMORY_IO)) == 0)
 		goto out;

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2007-04-26 13:50 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-13 18:08 [PATCH] dma_declare_coherent_memory wrong allocation Guennadi Liakhovetski
2007-04-21  7:08 ` Andrew Morton
2007-04-21 11:01   ` Guennadi Liakhovetski
2007-04-22 16:52 ` James Bottomley
2007-04-22 22:45   ` Guennadi Liakhovetski
2007-04-22 22:49     ` Guennadi Liakhovetski
2007-04-23 15:58     ` James Bottomley
2007-04-23 20:45       ` Guennadi Liakhovetski
2007-04-26 13:47         ` James Bottomley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox