Skip to content

Commit 7a0c4f9

Browse files
Anthony Yznagaopsiff
authored andcommitted
mm: fix unaccount of memory on vma_link() failure
mainline inclusion from mainline-v6.7-rc1 category: bugfix Fix insert_vm_struct() so that only accounted memory is unaccounted if vma_link() fails. Link: https://lkml.kernel.org/r/20230830004324.16101-1-anthony.yznaga@oracle.com Fixes: d4af56c ("mm: start tracking VMAs with maple tree") Signed-off-by: Anthony Yznaga <anthony.yznaga@oracle.com> Reviewed-by: Liam R. Howlett <Liam.Howlett@oracle.com> Cc: Matthew Wilcox (Oracle) <willy@infradead.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> (cherry picked from commit dd34d9f) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
1 parent 412dc00 commit 7a0c4f9

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

mm/mmap.c

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

33753375
if (vma_link(mm, vma)) {
3376-
vm_unacct_memory(charged);
3376+
if (vma->vm_flags & VM_ACCOUNT)
3377+
vm_unacct_memory(charged);
33773378
return -ENOMEM;
33783379
}
33793380

0 commit comments

Comments
 (0)