diff options
author | dg <dg@FreeBSD.org> | 1996-06-12 03:37:57 +0000 |
---|---|---|
committer | dg <dg@FreeBSD.org> | 1996-06-12 03:37:57 +0000 |
commit | 5026fc1c3662189cacaad4f0eb1fc0222ec8def1 (patch) | |
tree | 0244ce546b0fc6e415af50b64cc8c473ae6be049 /sys/miscfs/nullfs | |
parent | 6e349b6b4756260c2efd6d1e925c366e50db77d0 (diff) | |
download | FreeBSD-src-5026fc1c3662189cacaad4f0eb1fc0222ec8def1.zip FreeBSD-src-5026fc1c3662189cacaad4f0eb1fc0222ec8def1.tar.gz |
Moved the fsnode MALLOC to before the call to getnewvnode() so that the
process won't possibly block before filling in the fsnode pointer (v_data)
which might be dereferenced during a sync since the vnode is put on the
mnt_vnodelist by getnewvnode.
Pointed out by Matt Day <mday@artisoft.com>
Diffstat (limited to 'sys/miscfs/nullfs')
-rw-r--r-- | sys/miscfs/nullfs/null_subr.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/sys/miscfs/nullfs/null_subr.c b/sys/miscfs/nullfs/null_subr.c index e5fa590..4123dc2 100644 --- a/sys/miscfs/nullfs/null_subr.c +++ b/sys/miscfs/nullfs/null_subr.c @@ -35,7 +35,7 @@ * * @(#)null_subr.c 8.4 (Berkeley) 1/21/94 * - * $Id: null_subr.c,v 1.4 1995/12/03 14:38:49 bde Exp $ + * $Id: null_subr.c,v 1.5 1995/12/03 14:54:22 bde Exp $ */ #include <sys/param.h> @@ -162,12 +162,20 @@ null_node_alloc(mp, lowervp, vpp) struct vnode *othervp, *vp; int error; + /* + * Do the MALLOC before the getnewvnode since doing so afterward + * might cause a bogus v_data pointer to get dereferenced + * elsewhere if MALLOC should block. + */ + MALLOC(xp, struct null_node *, sizeof(struct null_node), M_TEMP, M_WAITOK); + error = getnewvnode(VT_NULL, mp, null_vnodeop_p, vpp); - if (error) + if (error) { + FREE(xp, M_TEMP); return (error); + } vp = *vpp; - MALLOC(xp, struct null_node *, sizeof(struct null_node), M_TEMP, M_WAITOK); vp->v_type = lowervp->v_type; xp->null_vnode = vp; vp->v_data = xp; |