diff options
Diffstat (limited to 'mm/mmap.c')
-rw-r--r-- | mm/mmap.c | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -2460,6 +2460,7 @@ int install_special_mapping(struct mm_struct *mm, | |||
2460 | unsigned long addr, unsigned long len, | 2460 | unsigned long addr, unsigned long len, |
2461 | unsigned long vm_flags, struct page **pages) | 2461 | unsigned long vm_flags, struct page **pages) |
2462 | { | 2462 | { |
2463 | int ret; | ||
2463 | struct vm_area_struct *vma; | 2464 | struct vm_area_struct *vma; |
2464 | 2465 | ||
2465 | vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL); | 2466 | vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL); |
@@ -2477,16 +2478,23 @@ int install_special_mapping(struct mm_struct *mm, | |||
2477 | vma->vm_ops = &special_mapping_vmops; | 2478 | vma->vm_ops = &special_mapping_vmops; |
2478 | vma->vm_private_data = pages; | 2479 | vma->vm_private_data = pages; |
2479 | 2480 | ||
2480 | if (unlikely(insert_vm_struct(mm, vma))) { | 2481 | ret = security_file_mmap(NULL, 0, 0, 0, vma->vm_start, 1); |
2481 | kmem_cache_free(vm_area_cachep, vma); | 2482 | if (ret) |
2482 | return -ENOMEM; | 2483 | goto out; |
2483 | } | 2484 | |
2485 | ret = insert_vm_struct(mm, vma); | ||
2486 | if (ret) | ||
2487 | goto out; | ||
2484 | 2488 | ||
2485 | mm->total_vm += len >> PAGE_SHIFT; | 2489 | mm->total_vm += len >> PAGE_SHIFT; |
2486 | 2490 | ||
2487 | perf_event_mmap(vma); | 2491 | perf_event_mmap(vma); |
2488 | 2492 | ||
2489 | return 0; | 2493 | return 0; |
2494 | |||
2495 | out: | ||
2496 | kmem_cache_free(vm_area_cachep, vma); | ||
2497 | return ret; | ||
2490 | } | 2498 | } |
2491 | 2499 | ||
2492 | static DEFINE_MUTEX(mm_all_locks_mutex); | 2500 | static DEFINE_MUTEX(mm_all_locks_mutex); |