]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
dmapool-make-dmapool_debug-detect-corruption-of-free-marker-fix
authorAndrew Morton <akpm@linux-foundation.org>
Thu, 29 Nov 2012 03:17:10 +0000 (14:17 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 5 Dec 2012 05:23:01 +0000 (16:23 +1100)
tidy code, fix comment, use sizeof(page->offset), use pr_err()

Cc: Matthieu Castet <matthieu.castet@parrot.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/dmapool.c

index ec03b13bc033770511aa1ccef54f01ed0c4c0b03..c69781e97cf968076583cc29ef1dbfa53a535c46 100644 (file)
@@ -336,23 +336,24 @@ void *dma_pool_alloc(struct dma_pool *pool, gfp_t mem_flags,
                int i;
                u8 *data = retval;
                /* page->offset is stored in first 4 bytes */
-               for (i = sizeof(int); i < pool->size; i++) {
-                       if (data[i] != POOL_POISON_FREED) {
-                               if (pool->dev)
-                                       dev_err(pool->dev,
-                                                       "dma_pool_alloc %s, %p (corruped)\n",
-                                                       pool->name, retval);
-                               else
-                                       printk(KERN_ERR
-                                                       "dma_pool_alloc %s, %p (corruped)\n",
-                                                       pool->name, retval);
-
-                               /* we dump the first 4 bytes even if there are not
-                                  POOL_POISON_FREED */
-                               print_hex_dump(KERN_ERR, "", DUMP_PREFIX_OFFSET, 16, 1,
-                                               data, pool->size, 1);
-                               break;
-                       }
+               for (i = sizeof(page->offset); i < pool->size; i++) {
+                       if (data[i] == POOL_POISON_FREED)
+                               continue;
+                       if (pool->dev)
+                               dev_err(pool->dev,
+                                       "dma_pool_alloc %s, %p (corruped)\n",
+                                       pool->name, retval);
+                       else
+                               pr_err("dma_pool_alloc %s, %p (corruped)\n",
+                                       pool->name, retval);
+
+                       /*
+                        * Dump the first 4 bytes even if they are not
+                        * POOL_POISON_FREED
+                        */
+                       print_hex_dump(KERN_ERR, "", DUMP_PREFIX_OFFSET, 16, 1,
+                                       data, pool->size, 1);
+                       break;
                }
        }
        memset(retval, POOL_POISON_ALLOCATED, pool->size);