diff options
author | Andrew Morton <akpm@linux-foundation.org> | 2022-11-30 14:58:42 -0800 |
---|---|---|
committer | Andrew Morton <akpm@linux-foundation.org> | 2022-11-30 14:58:42 -0800 |
commit | a38358c934f66bdff12db762998b88038d7bc44b (patch) | |
tree | 72747f34cde18a9e2188b6bccb865c14d423b986 /mm/mmap.c | |
parent | ea0ffd0c08d0fef1f6e93eb07badbeeabf6b43d6 (diff) | |
parent | 1d351f1894342c378b96bb9ed89f8debb1e24e9f (diff) | |
download | lwn-a38358c934f66bdff12db762998b88038d7bc44b.tar.gz lwn-a38358c934f66bdff12db762998b88038d7bc44b.zip |
Merge branch 'mm-hotfixes-stable' into mm-stable
Diffstat (limited to 'mm/mmap.c')
-rw-r--r-- | mm/mmap.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/mm/mmap.c b/mm/mmap.c index c697771d406b..4624ff3ded29 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -456,7 +456,7 @@ void vma_mas_remove(struct vm_area_struct *vma, struct ma_state *mas) * vma_mas_szero() - Set a given range to zero. Used when modifying a * vm_area_struct start or end. * - * @mm: The struct_mm + * @mas: The maple tree ma_state * @start: The start address to zero * @end: The end address to zero. */ @@ -2674,6 +2674,8 @@ cannot_expand: error = -EINVAL; if (file) goto close_and_free_vma; + else if (vma->vm_file) + goto unmap_and_free_vma; else goto free_vma; } @@ -2682,6 +2684,8 @@ cannot_expand: error = -ENOMEM; if (file) goto close_and_free_vma; + else if (vma->vm_file) + goto unmap_and_free_vma; else goto free_vma; } @@ -2751,7 +2755,7 @@ unmap_and_free_vma: /* Undo any partial mapping done by a device driver. */ unmap_region(mm, mas.tree, vma, prev, next, vma->vm_start, vma->vm_end); - if (vm_flags & VM_SHARED) + if (file && (vm_flags & VM_SHARED)) mapping_unmap_writable(file->f_mapping); free_vma: vm_area_free(vma); |