do_mbind(): fix memory leak

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>
This commit is contained in:
KOSAKI Motohiro 2009-10-26 16:49:59 -07:00 committed by Linus Torvalds
parent ab8a3e14e6
commit b05ca7385a
1 changed files with 5 additions and 5 deletions

View File

@ -1024,7 +1024,7 @@ static long do_mbind(unsigned long start, unsigned long len,
err = migrate_prep(); err = migrate_prep();
if (err) if (err)
return err; goto mpol_out;
} }
{ {
NODEMASK_SCRATCH(scratch); NODEMASK_SCRATCH(scratch);
@ -1039,10 +1039,9 @@ static long do_mbind(unsigned long start, unsigned long len,
err = -ENOMEM; err = -ENOMEM;
NODEMASK_SCRATCH_FREE(scratch); NODEMASK_SCRATCH_FREE(scratch);
} }
if (err) { if (err)
mpol_put(new); goto mpol_out;
return err;
}
vma = check_range(mm, start, end, nmask, vma = check_range(mm, start, end, nmask,
flags | MPOL_MF_INVERT, &pagelist); flags | MPOL_MF_INVERT, &pagelist);
@ -1062,6 +1061,7 @@ static long do_mbind(unsigned long start, unsigned long len,
putback_lru_pages(&pagelist); putback_lru_pages(&pagelist);
up_write(&mm->mmap_sem); up_write(&mm->mmap_sem);
mpol_out:
mpol_put(new); mpol_put(new);
return err; return err;
} }