Skip to content

Commit

Permalink
mm: nommu: fix a potential memory leak in do_mmap_private()
Browse files Browse the repository at this point in the history
If f_op->read() fails and sysctl_nr_trim_pages > 1, there could be a
memory leak between @region->vm_end and @region->vm_top.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Acked-by: Greg Ungerer <gerg@uclinux.org>
Cc: David Howells <dhowells@redhat.com>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Namhyung Kim authored and Linus Torvalds committed May 25, 2011
1 parent d75a310 commit 7223bb4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mm/nommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,7 @@ static int do_mmap_private(struct vm_area_struct *vma,
return 0;

error_free:
free_page_series(region->vm_start, region->vm_end);
free_page_series(region->vm_start, region->vm_top);
region->vm_start = vma->vm_start = 0;
region->vm_end = vma->vm_end = 0;
region->vm_top = 0;
Expand Down

0 comments on commit 7223bb4

Please sign in to comment.