Skip to content

Commit dd34d9f

Browse files
Anthony Yznagaakpm00
authored andcommitted
mm: fix unaccount of memory on vma_link() failure
Fix insert_vm_struct() so that only accounted memory is unaccounted if vma_link() fails. Link: https://lkml.kernel.org/r/[email protected] Fixes: d4af56c ("mm: start tracking VMAs with maple tree") Signed-off-by: Anthony Yznaga <[email protected]> Reviewed-by: Liam R. Howlett <[email protected]> Cc: Matthew Wilcox (Oracle) <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 954652b commit dd34d9f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

mm/mmap.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3278,7 +3278,8 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
32783278
}
32793279

32803280
if (vma_link(mm, vma)) {
3281-
vm_unacct_memory(charged);
3281+
if (vma->vm_flags & VM_ACCOUNT)
3282+
vm_unacct_memory(charged);
32823283
return -ENOMEM;
32833284
}
32843285

0 commit comments

Comments
 (0)