struct dma_pool {              /* the pool */
        struct list_head page_list;
        spinlock_t lock;
-       size_t size;
        struct device *dev;
-       size_t allocation;
-       size_t boundary;
+       unsigned int size;
+       unsigned int allocation;
+       unsigned int boundary;
        char name[32];
        struct list_head pools;
 };
        mutex_lock(&pools_lock);
        list_for_each_entry(pool, &dev->dma_pools, pools) {
                unsigned pages = 0;
-               unsigned blocks = 0;
+               size_t blocks = 0;
 
                spin_lock_irq(&pool->lock);
                list_for_each_entry(page, &pool->page_list, page_list) {
                spin_unlock_irq(&pool->lock);
 
                /* per-pool info, no real statistics yet */
-               size += sysfs_emit_at(buf, size, "%-16s %4u %4zu %4zu %2u\n",
+               size += sysfs_emit_at(buf, size, "%-16s %4zu %4zu %4u %2u\n",
                                      pool->name, blocks,
-                                     pages * (pool->allocation / pool->size),
+                                     (size_t) pages *
+                                     (pool->allocation / pool->size),
                                      pool->size, pages);
        }
        mutex_unlock(&pools_lock);
        else if (align & (align - 1))
                return NULL;
 
-       if (size == 0)
+       if (size == 0 || size > INT_MAX)
                return NULL;
        else if (size < 4)
                size = 4;
        else if ((boundary < size) || (boundary & (boundary - 1)))
                return NULL;
 
+       boundary = min(boundary, allocation);
+
        retval = kmalloc(sizeof(*retval), GFP_KERNEL);
        if (!retval)
                return retval;
 {
        unsigned long flags;
        struct dma_page *page;
-       size_t offset;
+       unsigned int offset;
        void *retval;
 
        might_alloc(mem_flags);