In bwrite, add assertion that vp != NULL. (vp is the vnode from the

buffer being written.)

There's some logic here that carefully checks for vp being null, and
other logic that will crash if it is. It appears that it's all
needless paranoia. See tech-kern for more info.

Unless someone sees the assertion go off (in which case a lot more
investigation is needed) I or someone will clean out the logic at some
future point.

Spotted by coypu.
This commit is contained in:
dholland 2016-07-31 04:05:32 +00:00
parent e8022dfde6
commit 28ccf570bf
1 changed files with 10 additions and 2 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: vfs_bio.c,v 1.259 2016/02/01 05:05:43 riz Exp $ */
/* $NetBSD: vfs_bio.c,v 1.260 2016/07/31 04:05:32 dholland Exp $ */
/*-
* Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc.
@ -123,7 +123,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.259 2016/02/01 05:05:43 riz Exp $");
__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.260 2016/07/31 04:05:32 dholland Exp $");
#ifdef _KERNEL_OPT
#include "opt_bufcache.h"
@ -800,6 +800,14 @@ bwrite(buf_t *bp)
KASSERT(!cv_has_waiters(&bp->b_done));
vp = bp->b_vp;
/*
* dholland 20160728 AFAICT vp==NULL must be impossible as it
* will crash upon reaching VOP_STRATEGY below... see further
* analysis on tech-kern.
*/
KASSERTMSG(vp != NULL, "bwrite given buffer with null vnode");
if (vp != NULL) {
KASSERT(bp->b_objlock == vp->v_interlock);
if (vp->v_type == VBLK)