Skip to contentSkip to conversation

arch/i386/kernel/pci-dma.c: ioremap balanced with iounmap

PATCH New Amol Lad 1 participant 1 message Oct 17, 2006

lore
Share & tools
lore

Amol Lad

author
#0 lore raw

PATCH 1/1 arch/i386/kernel/pci-dma.c: ioremap balanced with iounmap

ioremap must be balanced by an iounmap and failing to do so can result in a memory leak.

Tested (compilation only):
- using allmodconfig
- making sure the files are compiling without any warning/error due to new changes

---

arch/i386/kernel/pci-dma.c +3 -1
diff -uprN -X linux-2.6.19-rc1-orig/Documentation/dontdiff linux-2.6.19-rc1-orig/arch/i386/kernel/pci-dma.c linux-2.6.19-rc1/arch/i386/kernel/pci-dma.c
@@ -75,7 +75,7 @@ EXPORT_SYMBOL(dma_free_coherent);
 int dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
 				dma_addr_t device_addr, size_t size, int flags)
 {
-	void __iomem *mem_base;
+	void __iomem *mem_base = NULL;
 	int pages = size >> PAGE_SHIFT;
 	int bitmap_size = (pages + 31)/32;
 
@@ -114,6 +114,8 @@ int dma_declare_coherent_memory(struct d
  free1_out:
 	kfree(dev->dma_mem->bitmap);
  out:
+	if (mem_base)
+		iounmap(mem_base);
 	return 0;
 }
 EXPORT_SYMBOL(dma_declare_coherent_memory);