[PATCH] cciss endian annotations
[powerpc.git] / mm / vmalloc.c
index 6d381df..9eef486 100644 (file)
@@ -181,15 +181,12 @@ static struct vm_struct *__get_vm_area_node(unsigned long size, unsigned long fl
        }
        addr = ALIGN(start, align);
        size = PAGE_ALIGN(size);
-
-       area = kmalloc_node(sizeof(*area), gfp_mask, node);
-       if (unlikely(!area))
+       if (unlikely(!size))
                return NULL;
 
-       if (unlikely(!size)) {
-               kfree (area);
+       area = kmalloc_node(sizeof(*area), gfp_mask & GFP_LEVEL_MASK, node);
+       if (unlikely(!area))
                return NULL;
-       }
 
        /*
         * We always allocate a guard page.
@@ -532,11 +529,12 @@ void *vmalloc_user(unsigned long size)
        void *ret;
 
        ret = __vmalloc(size, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL);
-       write_lock(&vmlist_lock);
-       area = __find_vm_area(ret);
-       area->flags |= VM_USERMAP;
-       write_unlock(&vmlist_lock);
-
+       if (ret) {
+               write_lock(&vmlist_lock);
+               area = __find_vm_area(ret);
+               area->flags |= VM_USERMAP;
+               write_unlock(&vmlist_lock);
+       }
        return ret;
 }
 EXPORT_SYMBOL(vmalloc_user);
@@ -605,11 +603,12 @@ void *vmalloc_32_user(unsigned long size)
        void *ret;
 
        ret = __vmalloc(size, GFP_KERNEL | __GFP_ZERO, PAGE_KERNEL);
-       write_lock(&vmlist_lock);
-       area = __find_vm_area(ret);
-       area->flags |= VM_USERMAP;
-       write_unlock(&vmlist_lock);
-
+       if (ret) {
+               write_lock(&vmlist_lock);
+               area = __find_vm_area(ret);
+               area->flags |= VM_USERMAP;
+               write_unlock(&vmlist_lock);
+       }
        return ret;
 }
 EXPORT_SYMBOL(vmalloc_32_user);
@@ -700,7 +699,7 @@ finished:
  *     that it is big enough to cover the vma. Will return failure if
  *     that criteria isn't met.
  *
- *     Similar to remap_pfn_range (see mm/memory.c)
+ *     Similar to remap_pfn_range() (see mm/memory.c)
  */
 int remap_vmalloc_range(struct vm_area_struct *vma, void *addr,
                                                unsigned long pgoff)