From c4438f1892ddd18b31a672cfb7187198239e8afd Mon Sep 17 00:00:00 2001 From: dillon Date: Sun, 12 Aug 2007 16:57:31 +0000 Subject: [PATCH] Change the ordering of the zombie test for ^T to avoid a NULL pointer dereference panic. Reported-by: Stefan Krueger --- sys/kern/tty.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/sys/kern/tty.c b/sys/kern/tty.c index f300fbfd36..102ff2fc21 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -37,7 +37,7 @@ * * @(#)tty.c 8.8 (Berkeley) 1/21/94 * $FreeBSD: src/sys/kern/tty.c,v 1.129.2.5 2002/03/11 01:32:31 dd Exp $ - * $DragonFly: src/sys/kern/tty.c,v 1.42 2007/07/03 17:22:14 dillon Exp $ + * $DragonFly: src/sys/kern/tty.c,v 1.43 2007/08/12 16:57:31 dillon Exp $ */ /*- @@ -2484,6 +2484,18 @@ proc_compare(struct proc *p1, struct proc *p2) if (p1 == NULL) return (1); + /* + * weed out zombies + */ + switch (TESTAB(p1->p_stat == SZOMB, p2->p_stat == SZOMB)) { + case ONLYA: + return (1); + case ONLYB: + return (0); + case BOTH: + return (p2->p_pid > p1->p_pid); /* tie - return highest pid */ + } + /* XXX lwp */ lp1 = FIRST_LWP_IN_PROC(p1); lp2 = FIRST_LWP_IN_PROC(p2); @@ -2507,17 +2519,6 @@ proc_compare(struct proc *p1, struct proc *p2) return (p2->p_pid > p1->p_pid); /* tie - return highest pid */ } /* - * weed out zombies - */ - switch (TESTAB(p1->p_stat == SZOMB, p2->p_stat == SZOMB)) { - case ONLYA: - return (1); - case ONLYB: - return (0); - case BOTH: - return (p2->p_pid > p1->p_pid); /* tie - return highest pid */ - } - /* * pick the one with the smallest sleep time */ if (lp2->lwp_slptime > lp1->lwp_slptime) -- 2.11.4.GIT