From 3ea354e48a508f049271d8c1b146490402fd14e5 Mon Sep 17 00:00:00 2001 From: des Date: Mon, 6 Nov 2000 03:23:56 +0000 Subject: [PATCH] Check that p->p_pptr is not NULL - kernel processes have no parents! --- sys/compat/linprocfs/linprocfs.c | 4 ++-- sys/compat/linprocfs/linprocfs_misc.c | 4 ++-- sys/i386/linux/linprocfs/linprocfs_misc.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c index b985916bb565..d799fe406a9b 100644 --- a/sys/compat/linprocfs/linprocfs.c +++ b/sys/compat/linprocfs/linprocfs.c @@ -349,7 +349,7 @@ linprocfs_doprocstat(curp, p, pfs, uio) #define PS_ADD(name, fmt, arg) ps += sprintf(ps, " " fmt, arg) PS_ADD("comm", "(%s)", p->p_comm); PS_ADD("statr", "%c", '0'); /* XXX */ - PS_ADD("ppid", "%d", p->p_pptr->p_pid); + PS_ADD("ppid", "%d", p->p_pptr ? p->p_pptr->p_pid : 0); PS_ADD("pgrp", "%d", p->p_pgid); PS_ADD("session", "%d", p->p_session->s_sid); PS_ADD("tty", "%d", 0); /* XXX */ @@ -432,7 +432,7 @@ linprocfs_doprocstatus(curp, p, pfs, uio) * Credentials */ PS_ADD(ps, "Pid:\t%d\n", p->p_pid); - PS_ADD(ps, "PPid:\t%d\n", p->p_pptr->p_pid); + PS_ADD(ps, "PPid:\t%d\n", p->p_pptr ? p->p_pptr->p_pid : 0); PS_ADD(ps, "Uid:\t%d %d %d %d\n", p->p_cred->p_ruid, p->p_ucred->cr_uid, p->p_cred->p_svuid, diff --git a/sys/compat/linprocfs/linprocfs_misc.c b/sys/compat/linprocfs/linprocfs_misc.c index b985916bb565..d799fe406a9b 100644 --- a/sys/compat/linprocfs/linprocfs_misc.c +++ b/sys/compat/linprocfs/linprocfs_misc.c @@ -349,7 +349,7 @@ linprocfs_doprocstat(curp, p, pfs, uio) #define PS_ADD(name, fmt, arg) ps += sprintf(ps, " " fmt, arg) PS_ADD("comm", "(%s)", p->p_comm); PS_ADD("statr", "%c", '0'); /* XXX */ - PS_ADD("ppid", "%d", p->p_pptr->p_pid); + PS_ADD("ppid", "%d", p->p_pptr ? p->p_pptr->p_pid : 0); PS_ADD("pgrp", "%d", p->p_pgid); PS_ADD("session", "%d", p->p_session->s_sid); PS_ADD("tty", "%d", 0); /* XXX */ @@ -432,7 +432,7 @@ linprocfs_doprocstatus(curp, p, pfs, uio) * Credentials */ PS_ADD(ps, "Pid:\t%d\n", p->p_pid); - PS_ADD(ps, "PPid:\t%d\n", p->p_pptr->p_pid); + PS_ADD(ps, "PPid:\t%d\n", p->p_pptr ? p->p_pptr->p_pid : 0); PS_ADD(ps, "Uid:\t%d %d %d %d\n", p->p_cred->p_ruid, p->p_ucred->cr_uid, p->p_cred->p_svuid, diff --git a/sys/i386/linux/linprocfs/linprocfs_misc.c b/sys/i386/linux/linprocfs/linprocfs_misc.c index b985916bb565..d799fe406a9b 100644 --- a/sys/i386/linux/linprocfs/linprocfs_misc.c +++ b/sys/i386/linux/linprocfs/linprocfs_misc.c @@ -349,7 +349,7 @@ linprocfs_doprocstat(curp, p, pfs, uio) #define PS_ADD(name, fmt, arg) ps += sprintf(ps, " " fmt, arg) PS_ADD("comm", "(%s)", p->p_comm); PS_ADD("statr", "%c", '0'); /* XXX */ - PS_ADD("ppid", "%d", p->p_pptr->p_pid); + PS_ADD("ppid", "%d", p->p_pptr ? p->p_pptr->p_pid : 0); PS_ADD("pgrp", "%d", p->p_pgid); PS_ADD("session", "%d", p->p_session->s_sid); PS_ADD("tty", "%d", 0); /* XXX */ @@ -432,7 +432,7 @@ linprocfs_doprocstatus(curp, p, pfs, uio) * Credentials */ PS_ADD(ps, "Pid:\t%d\n", p->p_pid); - PS_ADD(ps, "PPid:\t%d\n", p->p_pptr->p_pid); + PS_ADD(ps, "PPid:\t%d\n", p->p_pptr ? p->p_pptr->p_pid : 0); PS_ADD(ps, "Uid:\t%d %d %d %d\n", p->p_cred->p_ruid, p->p_ucred->cr_uid, p->p_cred->p_svuid,