Skip to content

Commit fd9edbd

Browse files
howlettakpm00
authored andcommitted
nommu: fix split_vma() map_count error
During the maple tree conversion of nommu, an error in counting the VMAs was introduced by counting the existing VMA again. The counting used to be decremented by one and incremented by two, but now it only increments by two. Fix the counting error by moving the increment outside the setup_vma_to_mm() function to the callers. Link: https://lkml.kernel.org/r/[email protected] Fixes: 8220543 ("nommu: remove uses of VMA linked list") Signed-off-by: Liam R. Howlett <[email protected]> Cc: Matthew Wilcox (Oracle) <[email protected]> Cc: Vlastimil Babka <[email protected]> Cc: Yu Zhao <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 80be727 commit fd9edbd

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

mm/nommu.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,6 @@ void vma_mas_remove(struct vm_area_struct *vma, struct ma_state *mas)
559559

560560
static void setup_vma_to_mm(struct vm_area_struct *vma, struct mm_struct *mm)
561561
{
562-
mm->map_count++;
563562
vma->vm_mm = mm;
564563

565564
/* add the VMA to the mapping */
@@ -587,6 +586,7 @@ static void mas_add_vma_to_mm(struct ma_state *mas, struct mm_struct *mm,
587586
BUG_ON(!vma->vm_region);
588587

589588
setup_vma_to_mm(vma, mm);
589+
mm->map_count++;
590590

591591
/* add the VMA to the tree */
592592
vma_mas_store(vma, mas);
@@ -1347,6 +1347,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
13471347
if (vma->vm_file)
13481348
return -ENOMEM;
13491349

1350+
mm = vma->vm_mm;
13501351
if (mm->map_count >= sysctl_max_map_count)
13511352
return -ENOMEM;
13521353

@@ -1398,6 +1399,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
13981399
mas_set_range(&mas, vma->vm_start, vma->vm_end - 1);
13991400
mas_store(&mas, vma);
14001401
vma_mas_store(new, &mas);
1402+
mm->map_count++;
14011403
return 0;
14021404

14031405
err_mas_preallocate:

0 commit comments

Comments
 (0)