When the loop over the VMA is terminated early due to an error, the
return code could be overwritten with ENOMEM. Fix this by only setting
the error code when it is not set already.
Fixes: 2286a6914c77 ("mm: change mprotect_fixup to vma iterator")
Cc: <stable@vger.kernel.org>
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
tlb_gather_mmu(&tlb, current->mm);
nstart = start;
tmp = vma->vm_start;
+ error = 0;
for_each_vma_range(vmi, vma, end) {
unsigned long mask_off_old_flags;
unsigned long newflags;
}
tlb_finish_mmu(&tlb);
- if (vma_iter_end(&vmi) < end)
+ if (!error && vma_iter_end(&vmi) < end)
error = -ENOMEM;
out: