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/ufs/lfs/lfs_alloc.c | |
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/ufs/lfs/lfs_alloc.c')
-rw-r--r-- | sys/ufs/lfs/lfs_alloc.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/sys/ufs/lfs/lfs_alloc.c b/sys/ufs/lfs/lfs_alloc.c index 8d4e044..43b99f7 100644 --- a/sys/ufs/lfs/lfs_alloc.c +++ b/sys/ufs/lfs/lfs_alloc.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)lfs_alloc.c 8.4 (Berkeley) 1/4/94 - * $Id: lfs_alloc.c,v 1.9 1995/12/07 12:47:55 davidg Exp $ + * $Id: lfs_alloc.c,v 1.10 1996/01/05 18:31:51 wollman Exp $ */ #include "opt_quota.h" @@ -166,9 +166,17 @@ lfs_vcreate(mp, ino, vpp) struct ufsmount *ump; int error, i; + /* + * 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(ip, struct inode *, sizeof(struct inode), M_LFSNODE, M_WAITOK); + /* Create the vnode. */ if (error = getnewvnode(VT_LFS, mp, lfs_vnodeop_p, vpp)) { *vpp = NULL; + FREE(ip, M_LFSNODE); return (error); } @@ -176,7 +184,6 @@ lfs_vcreate(mp, ino, vpp) ump = VFSTOUFS(mp); /* Initialize the inode. */ - MALLOC(ip, struct inode *, sizeof(struct inode), M_LFSNODE, M_WAITOK); (*vpp)->v_data = ip; ip->i_vnode = *vpp; ip->i_devvp = ump->um_devvp; |