From e92d773fbcd978a10a0d332841a7c24671dc528b Mon Sep 17 00:00:00 2001 From: Robert Watson Date: Sat, 31 Mar 2007 16:08:50 +0000 Subject: [PATCH] Rather than ignoring any error return from getnewvnode() in nameiinit(), explicitly test and panic. This should not ever happen, but if it does, this is a preferred failure mode to a NULL pointer dereference in kernel. Coverity CID: 1716 Found with: Coverity Prevent(tm) --- sys/kern/vfs_lookup.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c index 464cc05e957b..e38ac719aae7 100644 --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -77,9 +77,13 @@ static struct vnode *vp_crossmp; static void nameiinit(void *dummy __unused) { + int error; + namei_zone = uma_zcreate("NAMEI", MAXPATHLEN, NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0); - getnewvnode("crossmp", NULL, &dead_vnodeops, &vp_crossmp); + error = getnewvnode("crossmp", NULL, &dead_vnodeops, &vp_crossmp); + if (error != 0) + panic("nameiinit: getnewvnode"); vp_crossmp->v_vnlock->lk_flags &= ~LK_NOSHARE; } SYSINIT(vfs, SI_SUB_VFS, SI_ORDER_SECOND, nameiinit, NULL)