Commit 5de55b26 authored by Matthieu CASTET's avatar Matthieu CASTET Committed by Linus Torvalds
Browse files

dmapool: make DMAPOOL_DEBUG detect corruption of free marker

This can help to catch the case where hardware is writing after dma free.

[ tidy code, fix comment, use sizeof(page->offset), use pr_err()]
Signed-off-by: default avatarMatthieu Castet <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent 9ff4868e
......@@ -332,6 +332,30 @@ void *dma_pool_alloc(struct dma_pool *pool, gfp_t mem_flags,
retval = offset + page->vaddr;
*handle = offset + page->dma;
int i;
u8 *data = retval;
/* page->offset is stored in first 4 bytes */
for (i = sizeof(page->offset); i < pool->size; i++) {
if (data[i] == POOL_POISON_FREED)
if (pool->dev)
"dma_pool_alloc %s, %p (corruped)\n",
pool->name, retval);
pr_err("dma_pool_alloc %s, %p (corruped)\n",
pool->name, retval);
* Dump the first 4 bytes even if they are not
print_hex_dump(KERN_ERR, "", DUMP_PREFIX_OFFSET, 16, 1,
data, pool->size, 1);
memset(retval, POOL_POISON_ALLOCATED, pool->size);
spin_unlock_irqrestore(&pool->lock, flags);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment