Skip to content

Commit

Permalink
do_mbind(): fix memory leak
Browse files Browse the repository at this point in the history
If migrate_prep is failed, new variable is leaked.  This patch fixes it.

Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Acked-by: Christoph Lameter <cl@linux-foundation.org>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
KOSAKI Motohiro authored and Linus Torvalds committed Oct 29, 2009
1 parent ab8a3e1 commit b05ca73
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions mm/mempolicy.c
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,7 @@ static long do_mbind(unsigned long start, unsigned long len,

err = migrate_prep();
if (err)
return err;
goto mpol_out;
}
{
NODEMASK_SCRATCH(scratch);
Expand All @@ -1039,10 +1039,9 @@ static long do_mbind(unsigned long start, unsigned long len,
err = -ENOMEM;
NODEMASK_SCRATCH_FREE(scratch);
}
if (err) {
mpol_put(new);
return err;
}
if (err)
goto mpol_out;

vma = check_range(mm, start, end, nmask,
flags | MPOL_MF_INVERT, &pagelist);

Expand All @@ -1062,6 +1061,7 @@ static long do_mbind(unsigned long start, unsigned long len,
putback_lru_pages(&pagelist);

up_write(&mm->mmap_sem);
mpol_out:
mpol_put(new);
return err;
}
Expand Down

0 comments on commit b05ca73

Please sign in to comment.