Commit b05ca738 authored by KOSAKI Motohiro's avatar KOSAKI Motohiro Committed by Linus Torvalds

do_mbind(): fix memory leak

If migrate_prep is failed, new variable is leaked.  This patch fixes it.
Signed-off-by: default avatarKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Acked-by: default avatarChristoph Lameter <cl@linux-foundation.org>
Cc: <stable@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent ab8a3e14
......@@ -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);
......@@ -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);
......@@ -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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment