From 5c0a1d4acce78a582187b5ab3d0d4d60b97d7557 Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Thu, 19 Dec 2013 14:04:56 -0600 Subject: [PATCH] DARWIN: Convert crfree back into a macro Commit 1d8937b860509fcaabb041bc14faf7aa3023f3c9 turned crfree on DARWIN into an inline function to work around an error flagged by clang. A side effect of this is that the address passed to kauth_cred_unref will not be the actual address of the value given to crfree; we are instead giving kauth_cred_unref the address of our function argument in order to adhere to the semantics of a function call. kauth_cred_unref seems to just take a pointer to the cred pointer in order to set the value to effectively NULL afterwards, so this is not a huge deal. However, this does mean that our current implementation undoes any of the safeguards intended by making kauth_cred_unref work this way in the first place. So, revert 1d8937b860509fcaabb041bc14faf7aa3023f3c9 and put the crfree definition back to the way it was. Fix the caller in afs_StoreOnLastReference to not cause an error by just assigning the cred pointer to a temporary value. While it's not ideal that some callers may need to do this, this is the only place where this is necessary and it's more of an artifact of the weirdness of storing a cred pointer in linkData, which probably should be changed anyway. Change-Id: I50557901203d22a7b19028be551eb40f0c4cd751 Reviewed-on: http://gerrit.openafs.org/10614 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- src/afs/DARWIN/osi_machdep.h | 2 +- src/afs/VNOPS/afs_vnop_write.c | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/afs/DARWIN/osi_machdep.h b/src/afs/DARWIN/osi_machdep.h index f513020860..175005291b 100644 --- a/src/afs/DARWIN/osi_machdep.h +++ b/src/afs/DARWIN/osi_machdep.h @@ -105,7 +105,7 @@ enum vcexcl { EXCL, NONEXCL }; #define crref kauth_cred_get_with_ref #define crhold kauth_cred_ref #ifdef AFS_DARWIN100_ENV -static inline void crfree(kauth_cred_t X) { kauth_cred_unref(&X); } +#define crfree(X) kauth_cred_unref(&X) #else #define crfree kauth_cred_rele #endif diff --git a/src/afs/VNOPS/afs_vnop_write.c b/src/afs/VNOPS/afs_vnop_write.c index 0f6007b593..5ef62aaead 100644 --- a/src/afs/VNOPS/afs_vnop_write.c +++ b/src/afs/VNOPS/afs_vnop_write.c @@ -47,6 +47,8 @@ afs_StoreOnLastReference(struct vcache *avc, * flag will already be clear, so we don't have to worry about * clearing it twice. */ if (avc->f.states & CCore) { + afs_ucred_t *cred; + avc->f.states &= ~CCore; #if defined(AFS_SGI_ENV) osi_Assert(avc->opens > 0 && avc->execsOrWriters > 0); @@ -58,7 +60,8 @@ afs_StoreOnLastReference(struct vcache *avc, avc->opens--; avc->execsOrWriters--; AFS_RELE(AFSTOV(avc)); /* VN_HOLD at set CCore(afs_FakeClose) */ - crfree((afs_ucred_t *)avc->linkData); /* "crheld" in afs_FakeClose */ + cred = (afs_ucred_t *)avc->linkData; /* "crheld" in afs_FakeClose */ + crfree(cred); avc->linkData = NULL; }