mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-18 16:44:27 +08:00
mm/vma: support vma == NULL in init_vma_munmap()
Adding support for a NULL vma means the init_vma_munmap() can be initialized for a less error-prone process when calling vms_complete_munmap_vmas() later on. Link: https://lkml.kernel.org/r/20240830040101.822209-11-Liam.Howlett@oracle.com Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com> Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com> Cc: Bert Karwatzki <spasswolf@web.de> Cc: Jeff Xu <jeffxu@chromium.org> Cc: Jiri Olsa <olsajiri@gmail.com> Cc: Kees Cook <kees@kernel.org> Cc: Lorenzo Stoakes <lstoakes@gmail.com> Cc: Mark Brown <broonie@kernel.org> Cc: Matthew Wilcox <willy@infradead.org> Cc: "Paul E. McKenney" <paulmck@kernel.org> Cc: Paul Moore <paul@paul-moore.com> Cc: Sidhartha Kumar <sidhartha.kumar@oracle.com> Cc: Suren Baghdasaryan <surenb@google.com> Cc: Vlastimil Babka <vbabka@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
9014b230d8
commit
58e60f8284
@ -1393,11 +1393,11 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
|
||||
|
||||
/* Find the first overlapping VMA */
|
||||
vma = vma_find(&vmi, end);
|
||||
init_vma_munmap(&vms, &vmi, vma, addr, end, uf, /* unlock = */ false);
|
||||
if (vma) {
|
||||
mt_init_flags(&mt_detach, vmi.mas.tree->ma_flags & MT_FLAGS_LOCK_MASK);
|
||||
mt_on_stack(mt_detach);
|
||||
mas_init(&mas_detach, &mt_detach, /* addr = */ 0);
|
||||
init_vma_munmap(&vms, &vmi, vma, addr, end, uf, /* unlock = */ false);
|
||||
/* Prepare to unmap any existing mapping in the area */
|
||||
error = vms_gather_munmap_vmas(&vms, &mas_detach);
|
||||
if (error)
|
||||
|
11
mm/vma.h
11
mm/vma.h
@ -95,9 +95,14 @@ static inline void init_vma_munmap(struct vma_munmap_struct *vms,
|
||||
{
|
||||
vms->vmi = vmi;
|
||||
vms->vma = vma;
|
||||
vms->mm = vma->vm_mm;
|
||||
vms->start = start;
|
||||
vms->end = end;
|
||||
if (vma) {
|
||||
vms->mm = vma->vm_mm;
|
||||
vms->start = start;
|
||||
vms->end = end;
|
||||
} else {
|
||||
vms->mm = NULL;
|
||||
vms->start = vms->end = 0;
|
||||
}
|
||||
vms->unlock = unlock;
|
||||
vms->uf = uf;
|
||||
vms->vma_count = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user