mm/mmap: properly unaccount memory on mas_preallocate() failure
authorAlistair Popple <apopple@nvidia.com>
Fri, 2 Dec 2022 04:53:39 +0000 (15:53 +1100)
committerAndrew Morton <akpm@linux-foundation.org>
Mon, 12 Dec 2022 02:12:18 +0000 (18:12 -0800)
commit675eaca1f441acd4f0d403d71036b100cd49036a
tree2bca8186188b04dcf326d50d6b713afb6e0a6a72
parent1bda9dad5aa0199c8592bac32b91afbf8ea236ff
mm/mmap: properly unaccount memory on mas_preallocate() failure

security_vm_enough_memory_mm() accounts memory via a call to
vm_acct_memory().  Therefore any subsequent failures should unaccount for
this memory prior to returning the error.

Link: https://lkml.kernel.org/r/20221202045339.2999017-1-apopple@nvidia.com
Fixes: 28c5609fb236 ("mm/mmap: preallocate maple nodes for brk vma expansion")
Signed-off-by: Alistair Popple <apopple@nvidia.com>
Reviewed-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/mmap.c