[PATCH v2] lib/dma-debug: check for vmalloc and module addresses used with the DMA-API

From: Jan Luebbe
Date: Wed Sep 19 2012 - 11:29:05 EST


Signed-off-by: Jan Luebbe <jlu@xxxxxxxxxxxxxx>
---

Changes since v1:
- As recommended by Joerg Roedel, check for overlap with vmalloc and
module address ranges.

lib/dma-debug.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/lib/dma-debug.c b/lib/dma-debug.c
index 66ce414..b35992b 100644
--- a/lib/dma-debug.c
+++ b/lib/dma-debug.c
@@ -944,6 +944,14 @@ static void check_for_illegal_area(struct device *dev, void *addr, unsigned long
if (overlap(addr, len, _text, _etext) ||
overlap(addr, len, __start_rodata, __end_rodata))
err_printk(dev, NULL, "DMA-API: device driver maps memory from kernel text or rodata [addr=%p] [len=%lu]\n", addr, len);
+#ifdef CONFIG_MMU
+ if (overlap(addr, len, (void *)VMALLOC_START, (void *)VMALLOC_END))
+ err_printk(dev, NULL, "DMA-API: device driver maps memory from vmalloc address range [addr=%p] [len=%lu]\n", addr, len);
+#endif
+#if defined(CONFIG_MODULES) && defined(MODULES_VADDR)
+ if (overlap(addr, len, (void *)MODULES_VADDR, (void *)MODULES_END))
+ err_printk(dev, NULL, "DMA-API: device driver maps memory from kernel module address range [addr=%p] [len=%lu]\n", addr, len);
+#endif
}

static void check_sync(struct device *dev,
--
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/