Cleanup.  Every linux_binfmt->core_dump() sets PF_DUMPCORE, move this into
zap_threads() called by do_coredump().
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Mandeep Singh Baines <msb@chromium.org>
Cc: Neil Horman <nhorman@redhat.com>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
        fs = get_fs();
        set_fs(KERNEL_DS);
        has_dumped = 1;
-       current->flags |= PF_DUMPCORE;
        strncpy(dump.u_comm, current->comm, sizeof(current->comm));
        dump.u_ar0 = offsetof(struct user32, regs);
        dump.signal = signr;
 
        fs = get_fs();
        set_fs(KERNEL_DS);
        has_dumped = 1;
-       current->flags |= PF_DUMPCORE;
                strncpy(dump.u_comm, current->comm, sizeof(dump.u_comm));
        dump.u_ar0 = offsetof(struct user, regs);
        dump.signal = cprm->siginfo->si_signo;
 
                goto cleanup;
 
        has_dumped = 1;
-       current->flags |= PF_DUMPCORE;
-  
+
        fs = get_fs();
        set_fs(KERNEL_DS);
 
 
        fill_elf_fdpic_header(elf, e_phnum);
 
        has_dumped = 1;
-       current->flags |= PF_DUMPCORE;
-
        /*
         * Set up the notes in similar form to SVR4 core dumps made
         * with info from their /proc.
 
        if (unlikely(nr < 0))
                return nr;
 
+       tsk->flags = PF_DUMPCORE;
        if (atomic_read(&mm->mm_users) == nr + 1)
                goto done;
        /*