summaryrefslogtreecommitdiffstats
path: root/sys/miscfs/fdesc
diff options
context:
space:
mode:
authordg <dg@FreeBSD.org>1996-06-12 03:37:57 +0000
committerdg <dg@FreeBSD.org>1996-06-12 03:37:57 +0000
commit5026fc1c3662189cacaad4f0eb1fc0222ec8def1 (patch)
tree0244ce546b0fc6e415af50b64cc8c473ae6be049 /sys/miscfs/fdesc
parent6e349b6b4756260c2efd6d1e925c366e50db77d0 (diff)
downloadFreeBSD-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/fdesc')
-rw-r--r--sys/miscfs/fdesc/fdesc_vnops.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/sys/miscfs/fdesc/fdesc_vnops.c b/sys/miscfs/fdesc/fdesc_vnops.c
index bec6bc7..c563298 100644
--- a/sys/miscfs/fdesc/fdesc_vnops.c
+++ b/sys/miscfs/fdesc/fdesc_vnops.c
@@ -35,7 +35,7 @@
*
* @(#)fdesc_vnops.c 8.9 (Berkeley) 1/21/94
*
- * $Id: fdesc_vnops.c,v 1.14 1995/12/05 19:12:05 bde Exp $
+ * $Id: fdesc_vnops.c,v 1.15 1995/12/08 11:17:40 julian Exp $
*/
/*
@@ -170,10 +170,18 @@ loop:
}
fdcache_lock |= FDL_LOCKED;
+ /*
+ * 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(fd, struct fdescnode *, sizeof(struct fdescnode), M_TEMP, M_WAITOK);
+
error = getnewvnode(VT_FDESC, mp, fdesc_vnodeop_p, vpp);
- if (error)
+ if (error) {
+ FREE(fd, M_TEMP);
goto out;
- MALLOC(fd, void *, sizeof(struct fdescnode), M_TEMP, M_WAITOK);
+ }
(*vpp)->v_data = fd;
fd->fd_vnode = *vpp;
fd->fd_type = ftype;
OpenPOWER on IntegriCloud