]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/miscfs/union/union_subr.c
xnu-792.21.3.tar.gz
[apple/xnu.git] / bsd / miscfs / union / union_subr.c
index 7eff77ebcd5ba86b27d5809fd05aebbad072f7fa..80b3a0386ecf5139e2971c954d507e673b4f354a 100644 (file)
@@ -882,6 +882,7 @@ union_vn_create(vpp, un, p)
        struct proc *p;
 {
        struct vnode *vp;
+       kauth_cred_t cred = p->p_ucred;
        struct vnode_attr vat;
        struct vnode_attr *vap = &vat;
        struct vfs_context context;
@@ -894,7 +895,7 @@ union_vn_create(vpp, un, p)
        *vpp = NULLVP;
 
        context.vc_proc = p;
-       context.vc_ucred = kauth_cred_proc_ref(p);
+       context.vc_ucred = p->p_ucred;
 
        /*
         * Build a new componentname structure (for the same
@@ -918,15 +919,12 @@ union_vn_create(vpp, un, p)
        cn.cn_consume = 0;
 
        vnode_get(un->un_dirvp);
-       if (error = relookup(un->un_dirvp, &vp, &cn)) {
-               kauth_cred_unref(&context.vc_ucred);
+       if (error = relookup(un->un_dirvp, &vp, &cn))
                return (error);
-       }
        vnode_put(un->un_dirvp);
 
        if (vp) {
                vnode_put(un->un_dirvp);
-               kauth_cred_unref(&context.vc_ucred);
                vnode_put(vp);
                return (EEXIST);
        }
@@ -948,14 +946,11 @@ union_vn_create(vpp, un, p)
        VATTR_SET(vap, va_type, VREG);
        VATTR_SET(vap, va_mode, cmode);
 
-       if (error = vn_create(un->un_dirvp, &vp, &cn, vap, 0, &context)) {
-               kauth_cred_unref(&context.vc_ucred);
+       if (error = vn_create(un->un_dirvp, &vp, &cn, vap, 0, &context))
                return (error);
-       }
 
        if (error = VNOP_OPEN(vp, fmode, &context)) {
                vnode_put(vp);
-               kauth_cred_unref(&context.vc_ucred);
                return (error);
        }
 
@@ -964,7 +959,6 @@ union_vn_create(vpp, un, p)
                panic("union: v_writecount");
        vnode_unlock(vp);
        *vpp = vp;
-       kauth_cred_unref(&context.vc_ucred);
        return (0);
 }