rmap: fix anon_vma_fork() memory leak

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linux Kernel Mailing List
Date: Monday, April 5, 2010 - 12:59 pm

Gitweb:     http://git.kernel.org/linus/4946d54cb55e86a156216fcfeed5568514b0830f
Commit:     4946d54cb55e86a156216fcfeed5568514b0830f
Parent:     db217dece3003df0841bacf9556b5c06aa097dae
Author:     Rik van Riel <riel@redhat.com>
AuthorDate: Mon Apr 5 12:13:33 2010 -0400
Committer:  Linus Torvalds <torvalds@linux-foundation.org>
CommitDate: Mon Apr 5 09:15:51 2010 -0700

    rmap: fix anon_vma_fork() memory leak
    
    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>
---
 mm/rmap.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/mm/rmap.c b/mm/rmap.c
index fcd593c..eaa7a09 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -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;
 }
 
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
rmap: fix anon_vma_fork() memory leak, Linux Kernel Mailing ..., (Mon Apr 5, 12:59 pm)