From c8e4c454f21aa3fa3bd2357c0775e8102358682a Mon Sep 17 00:00:00 2001 From: cgd Date: Tue, 15 Oct 1996 23:06:27 +0000 Subject: [PATCH] curproc was being used directly for ru_{in,ou}block counting. Instead of using it directly, use a local, and set that local to be curproc if curproc is not NULL else a pointer to process 0's proc struct. If syncing disks while handling a panic that occurred while 'curproc' was NULL, the old code would dereference NULL and die. --- sys/kern/vfs_bio.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index f0538265439b..776fbe99d1fb 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_bio.c,v 1.48 1996/10/13 02:32:48 christos Exp $ */ +/* $NetBSD: vfs_bio.c,v 1.49 1996/10/15 23:06:27 cgd Exp $ */ /*- * Copyright (c) 1994 Christopher G. Demetriou @@ -170,6 +170,7 @@ bio_doread(vp, blkno, size, cred, async) int async; { register struct buf *bp; + struct proc *p = (curproc != NULL ? curproc : &proc0); /* XXX */ bp = getblk(vp, blkno, size, 0, 0); @@ -188,7 +189,7 @@ bio_doread(vp, blkno, size, cred, async) VOP_STRATEGY(bp); /* Pay for the read. */ - curproc->p_stats->p_ru.ru_inblock++; /* XXX */ + p->p_stats->p_ru.ru_inblock++; } else if (async) { brelse(bp); } @@ -276,6 +277,7 @@ bwrite(bp) struct buf *bp; { int rv, sync, wasdelayed, s; + struct proc *p = (curproc != NULL ? curproc : &proc0); /* XXX */ /* * Remember buffer type, to switch on it later. If the write was @@ -303,7 +305,7 @@ bwrite(bp) if (wasdelayed) reassignbuf(bp, bp->b_vp); else - curproc->p_stats->p_ru.ru_oublock++; + p->p_stats->p_ru.ru_oublock++; /* Initiate disk write. Make sure the appropriate party is charged. */ bp->b_vp->v_numoutput++; @@ -352,6 +354,7 @@ bdwrite(bp) struct buf *bp; { int s; + struct proc *p = (curproc != NULL ? curproc : &proc0); /* XXX */ /* If this is a tape block, write the block now. */ if (bdevsw[major(bp->b_dev)].d_type == D_TAPE) { @@ -367,7 +370,7 @@ bdwrite(bp) */ if (!ISSET(bp->b_flags, B_DELWRI)) { SET(bp->b_flags, B_DELWRI); - curproc->p_stats->p_ru.ru_oublock++; + p->p_stats->p_ru.ru_oublock++; s = splbio(); reassignbuf(bp, bp->b_vp); splx(s);