]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/hfs/hfs_quota.c
xnu-792.21.3.tar.gz
[apple/xnu.git] / bsd / hfs / hfs_quota.c
index b2945e081d3739ba7cc58698ff88eb6e40058036..1354664f740b8a61c23d4036dadce14e6e312e43 100644 (file)
@@ -169,11 +169,7 @@ hfs_chkdq(cp, change, cred, flags)
                return (0);
        }
        p = current_proc();
-       /*
-        * This use of proc_ucred() is safe because kernproc credential never
-        * changes.
-        */
-       if (!IS_VALID_CRED(cred))
+       if (cred == NOCRED)
                cred = proc_ucred(kernproc);
        if (suser(cred, NULL) || proc_forcequota(p)) {
                for (i = 0; i < MAXQUOTAS; i++) {
@@ -314,11 +310,7 @@ hfs_chkiq(cp, change, cred, flags)
                return (0);
        }
        p = current_proc();
-       /*
-        * This use of proc_ucred() is safe because kernproc credential never
-        * changes.
-        */
-       if (!IS_VALID_CRED(cred))
+       if (cred == NOCRED)
                cred = proc_ucred(kernproc);
        if (suser(cred, NULL) || proc_forcequota(p)) {
                for (i = 0; i < MAXQUOTAS; i++) {
@@ -509,8 +501,8 @@ hfs_quotaon(p, mp, type, fnamep)
        if (error) {
                (void) vnode_close(vp, FREAD|FWRITE, NULL);
 
-               if (IS_VALID_CRED(qfp->qf_cred))
-                       kauth_cred_unref(&qfp->qf_cred);
+               kauth_cred_rele(qfp->qf_cred);
+               qfp->qf_cred = NOCRED;
                qfp->qf_vp = NULLVP;
                goto out;
        }
@@ -577,6 +569,7 @@ hfs_quotaoff(__unused struct proc *p, struct mount *mp, register int type)
        struct hfsmount *hfsmp = VFSTOHFS(mp);
        struct quotafile *qfp;
        int error;
+       kauth_cred_t cred;
        struct hfs_quotaoff_cargs args;
 
        qfp = &hfsmp->hfs_qfiles[type];
@@ -611,9 +604,11 @@ hfs_quotaoff(__unused struct proc *p, struct mount *mp, register int type)
        error = vnode_close(qvp, FREAD|FWRITE, NULL);
 
        qfp->qf_vp = NULLVP;
-
-       if (IS_VALID_CRED(qfp->qf_cred))
-               kauth_cred_unref(&qfp->qf_cred);
+       cred = qfp->qf_cred;
+       if (cred != NOCRED) {
+               qfp->qf_cred = NOCRED;
+               kauth_cred_rele(cred);
+       }
        for (type = 0; type < MAXQUOTAS; type++)
                if (hfsmp->hfs_qfiles[type].qf_vp != NULLVP)
                        break;