Skip to contentSkip to conversation

mm/mmap: Avoid dereferencing next on null in BUG_ON()

PATCH New Liam Howlett 1 participant 1 message May 19, 2022

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

PATCH 1/1 mm/mmap: Avoid dereferencing next on null in BUG_ON()

Check there is a next before checking the bounds.

---
 mm/mmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/mmap.c +1 -1
index 4279e2acd243..f1fc9c5c068b 100644
@@ -583,7 +583,7 @@ inline int vma_expand(struct ma_state *mas, struct vm_area_struct *vma,
 	}
 
 	/* Not merging but overwriting any part of next is not handled. */
-	VM_BUG_ON(!remove_next && next != vma && end > next->vm_start);
+	VM_BUG_ON(next && !remove_next && next != vma && end > next->vm_start);
 	/* Only handles expanding */
 	VM_BUG_ON(vma->vm_start < start || vma->vm_end > end);
 
Signature · 1 line
2.35.1