mas_store() should not fail, but protect against potential failures by checking the maple state for mas_is_err(). Fixes: 57579b57de57 (kernel/fork: use maple tree for dup_mmap() during forking) Signed-off-by: Liam R. Howlett <Liam.Howlett@xxxxxxxxxx> --- kernel/fork.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kernel/fork.c b/kernel/fork.c index 2d7ce88da540..dfa2d5d22ed1 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -685,6 +685,8 @@ static __latent_entropy int dup_mmap(struct mm_struct *mm, mas.index = tmp->vm_start; mas.last = tmp->vm_end - 1; mas_store(&mas, tmp); + if (mas_is_err(&mas)) + goto fail_nomem_mas_store; mm->map_count++; if (!(tmp->vm_flags & VM_WIPEONFORK)) @@ -708,6 +710,9 @@ static __latent_entropy int dup_mmap(struct mm_struct *mm, fail_uprobe_end: uprobe_end_dup_mmap(); return retval; + +fail_nomem_mas_store: + unlink_anon_vmas(tmp); fail_nomem_anon_vma_fork: mpol_put(vma_policy(tmp)); fail_nomem_policy: -- 2.35.1