[PATCH] PCI: pci pool, poison more like slab code
This adds a new poisoning mode, distinguishing memory
that's uninitialized from memory that's freed. The
slab code has been doing this for a while now.
drivers/pci/pool.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff -Nru a/drivers/pci/pool.c b/drivers/pci/pool.c
--- a/drivers/pci/pool.c Tue Jun 10 11:15:19 2003
+++ b/drivers/pci/pool.c Tue Jun 10 11:15:19 2003
@@ -29,7 +29,8 @@
};
#define POOL_TIMEOUT_JIFFIES ((100 /* msec */ * HZ) / 1000)
-#define POOL_POISON_BYTE 0xa7
+#define POOL_POISON_FREED 0xa7 /* !inuse */
+#define POOL_POISON_ALLOCATED 0xa9 /* !initted */
static DECLARE_MUTEX (pools_lock);
@@ -172,7 +173,7 @@
if (page->vaddr) {
memset (page->bitmap, 0xff, mapsize); // bit set == free
#ifdef CONFIG_DEBUG_SLAB
- memset (page->vaddr, POOL_POISON_BYTE, pool->allocation);
+ memset (page->vaddr, POOL_POISON_FREED, pool->allocation);
#endif
list_add (&page->page_list, &pool->page_list);
page->in_use = 0;
@@ -201,7 +202,7 @@
dma_addr_t dma = page->dma;
#ifdef CONFIG_DEBUG_SLAB
- memset (page->vaddr, POOL_POISON_BYTE, pool->allocation);
+ memset (page->vaddr, POOL_POISON_FREED, pool->allocation);
#endif
pci_free_consistent (pool->dev, pool->allocation, page->vaddr, dma);
list_del (&page->page_list);
@@ -309,6 +310,9 @@
page->in_use++;
retval = offset + page->vaddr;
*handle = offset + page->dma;
+#ifdef CONFIG_DEBUG_SLAB
+ memset (retval, POOL_POISON_ALLOCATED, pool->size);
+#endif
done:
spin_unlock_irqrestore (&pool->lock, flags);
return retval;
@@ -378,7 +382,7 @@
pool->name, (unsigned long long)dma);
return;
}
- memset (vaddr, POOL_POISON_BYTE, pool->size);
+ memset (vaddr, POOL_POISON_FREED, pool->size);
#endif
spin_lock_irqsave (&pool->lock, flags);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/