Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/ufs/ufs Fix error path for UFS_WAPBL_BEGIN failure to av...



details:   https://anonhg.NetBSD.org/src/rev/13816b067628
branches:  trunk
changeset: 767410:13816b067628
user:      dholland <dholland%NetBSD.org@localhost>
date:      Mon Jul 18 01:13:33 2011 +0000

description:
Fix error path for UFS_WAPBL_BEGIN failure to avoid leaking an vnode
(in memory) and inode (on disk). Caution: untested; I have no idea how
to provoke such a failure.

diffstat:

 sys/ufs/ufs/ufs_vnops.c |  15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

diffs (38 lines):

diff -r 14aa02929a99 -r 13816b067628 sys/ufs/ufs/ufs_vnops.c
--- a/sys/ufs/ufs/ufs_vnops.c   Mon Jul 18 00:58:51 2011 +0000
+++ b/sys/ufs/ufs/ufs_vnops.c   Mon Jul 18 01:13:33 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ufs_vnops.c,v 1.195 2011/07/17 22:02:26 dholland Exp $ */
+/*     $NetBSD: ufs_vnops.c,v 1.196 2011/07/18 01:13:33 dholland Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.195 2011/07/17 22:02:26 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.196 2011/07/18 01:13:33 dholland Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -1412,11 +1412,16 @@
         */
        if ((error = UFS_VALLOC(dvp, dmode, cnp->cn_cred, ap->a_vpp)) != 0)
                goto out;
-       error = UFS_WAPBL_BEGIN(ap->a_dvp->v_mount);
-       if (error)
-               goto out;
+
        tvp = *ap->a_vpp;
        ip = VTOI(tvp);
+
+       error = UFS_WAPBL_BEGIN(ap->a_dvp->v_mount);
+       if (error) {
+               UFS_VFREE(tvp, ip->i_number, dmode);
+               vput(tvp);
+               goto out;
+       }
        ip->i_uid = kauth_cred_geteuid(cnp->cn_cred);
        DIP_ASSIGN(ip, uid, ip->i_uid);
        ip->i_gid = dp->i_gid;



Home | Main Index | Thread Index | Old Index