Skip to contentSkip to conversation

mm/mmap: Fix copy_vma() new_vma check

PATCH New Liam Howlett 1 participant 1 message Jul 6, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm/mmap: Fix copy_vma() new_vma check

When checking new_vma limits to ensure they are not within where the copy of the vma will be placed, ensure new_vma is not NULL.

Fixes ded0cf440d9b (mm: remove the vma linked list)
---
 mm/mmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/mmap.c +1 -1
index dacc01b0126a..9eb663cde5c7 100644
@@ -3293,7 +3293,7 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
 	}
 
 	new_vma = find_vma_prev(mm, addr, &prev);
-	if (new_vma->vm_start < addr + len)
+	if (new_vma && new_vma->vm_start < addr + len)
 		return NULL;	/* should never get here */
 
 	new_vma = vma_merge(mm, prev, addr, addr + len, vma->vm_flags,
Signature · 1 line
2.35.1