There is a leak when the system is low on resources and fails to
allocate enough memory to complete the munmap task. Fix this by adding
the necessary free operations in the unwinding.
Fixes: a760774e7b7b (mm: start tracking VMAs with maple tree)
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
return -ENOMEM;
if (mas_preallocate(&mas_detach, vma, GFP_KERNEL))
- return -ENOMEM;
+ goto detach_alloc_fail;
mas->last = end - 1;
/* If we need to split any vma, do it now to save pain later. */
map_count_exceeded:
split_failed:
userfaultfd_error:
+ mas_destroy(&mas_detach);
+detach_alloc_fail:
mas_destroy(mas);
return error;
}