diff --git a/mm/mmap.c b/mm/mmap.c index b22f5319f2e0..f9787c2ef573 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2696,7 +2696,7 @@ cannot_expand: if (!arch_validate_flags(vma->vm_flags)) { error = -EINVAL; if (file) - goto unmap_and_free_vma; + goto close_and_free_vma; else goto free_vma; } @@ -2765,6 +2765,9 @@ expanded: validate_mm(mm); return addr; +close_and_free_vma: + if (vma->vm_ops && vma->vm_ops->close) + vma->vm_ops->close(vma); unmap_and_free_vma: fput(vma->vm_file); vma->vm_file = NULL;