]> git.hungrycats.org Git - linux/commitdiff
[PATCH] NUMA API: fix use-after-free bug
authorAndi Kleen <ak@muc.de>
Tue, 6 Jul 2004 16:19:24 +0000 (09:19 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Tue, 6 Jul 2004 16:19:24 +0000 (09:19 -0700)
Move the memory policy freeing to later in exit to make sure the last
memory allocations don't use an uninitialized policy.

Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
kernel/exit.c

index cf71b30d8bd5992cec0fe411126969cea9471c29..2bab0bf9fe9704da3b3a8f99b76e487dcbb87651 100644 (file)
@@ -828,9 +828,6 @@ asmlinkage NORET_TYPE void do_exit(long code)
        __exit_fs(tsk);
        exit_namespace(tsk);
        exit_thread();
-#ifdef CONFIG_NUMA
-       mpol_free(tsk->mempolicy);
-#endif
 
        if (tsk->signal->leader)
                disassociate_ctty(1);
@@ -841,6 +838,10 @@ asmlinkage NORET_TYPE void do_exit(long code)
 
        tsk->exit_code = code;
        exit_notify(tsk);
+#ifdef CONFIG_NUMA
+       mpol_free(tsk->mempolicy);
+       tsk->mempolicy = NULL;
+#endif
        schedule();
        BUG();
        /* Avoid "noreturn function does return".  */