Merge branch 'upstream-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/linvil...
[pandora-kernel.git] / drivers / base / dmapool.c
index e2f64f9..b2efbd4 100644 (file)
@@ -7,6 +7,7 @@
 #include <linux/dmapool.h>
 #include <linux/slab.h>
 #include <linux/module.h>
+#include <linux/poison.h>
 
 /*
  * Pool allocator ... wraps the dma_alloc_coherent page allocator, so
@@ -35,8 +36,6 @@ struct dma_page {     /* cacheable header for 'allocation' bytes */
 };
 
 #define        POOL_TIMEOUT_JIFFIES    ((100 /* msec */ * HZ) / 1000)
-#define        POOL_POISON_FREED       0xa7    /* !inuse */
-#define        POOL_POISON_ALLOCATED   0xa9    /* !initted */
 
 static DECLARE_MUTEX (pools_lock);
 
@@ -142,11 +141,20 @@ dma_pool_create (const char *name, struct device *dev,
        init_waitqueue_head (&retval->waitq);
 
        if (dev) {
+               int ret;
+
                down (&pools_lock);
                if (list_empty (&dev->dma_pools))
-                       device_create_file (dev, &dev_attr_pools);
+                       ret = device_create_file (dev, &dev_attr_pools);
+               else
+                       ret = 0;
                /* note:  not currently insisting "name" be unique */
-               list_add (&retval->pools, &dev->dma_pools);
+               if (!ret)
+                       list_add (&retval->pools, &dev->dma_pools);
+               else {
+                       kfree(retval);
+                       retval = NULL;
+               }
                up (&pools_lock);
        } else
                INIT_LIST_HEAD (&retval->pools);