kernel_migrate_pages() calls put_task_struct() twice; this complicates the code. Move put_task_struct() to the unified exit path. This also allows us to move the "out_put" label up and avoid another goto. Signed-off-by: Oleg Nesterov --- mm/mempolicy.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 4e4421b22b59..4326dff16aa6 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -1922,25 +1922,20 @@ static int kernel_migrate_pages(pid_t pid, unsigned long maxnode, goto out_put; mm = get_task_mm(task); - put_task_struct(task); - if (!mm) { err = -EINVAL; - goto out; + goto out_put; } err = do_migrate_pages(mm, old, new, capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE); mmput(mm); +out_put: + put_task_struct(task); out: NODEMASK_SCRATCH_FREE(scratch); - return err; - -out_put: - put_task_struct(task); - goto out; } SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode, -- 2.52.0