Skip to content

Commit

Permalink
rmap: fix anon_vma_fork() memory leak
Browse files Browse the repository at this point in the history
Fix a memory leak in anon_vma_fork(), where we fail to tear down the
anon_vmas attached to the new VMA in case setting up the new anon_vma
fails.

This bug also has the potential to leave behind anon_vma_chain structs
with pointers to invalid memory.

Reported-by: Minchan Kim <minchan.kim@gmail.com>
Signed-off-by: Rik van Riel <riel@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Rik van Riel authored and torvalds committed Apr 5, 2010
1 parent db217de commit 4946d54
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions mm/rmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
out_error_free_anon_vma:
anon_vma_free(anon_vma);
out_error:
unlink_anon_vmas(vma);
return -ENOMEM;
}

Expand Down

0 comments on commit 4946d54

Please sign in to comment.