From c9846c9e804299de41a298adf69c9c0666d8ec85 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Thu, 7 Mar 2013 17:28:36 -0500 Subject: [PATCH] Windows: AFSLocateNameEntry OutVolumeCB can be NULL It is possible for the AFSLocateNameEntry OutVolumeCB parameter to be assigned a NULL value upon return. Handle it in the callers. Change-Id: I15e4581d4655dbaca7c4ca4b9e9af758e97c5c95 Reviewed-on: http://gerrit.openafs.org/9464 Tested-by: BuildBot Reviewed-by: Rod Widdowson Reviewed-by: Jeffrey Altman --- src/WINNT/afsrdr/kernel/lib/AFSCreate.cpp | 44 ++++---- src/WINNT/afsrdr/kernel/lib/AFSGeneric.cpp | 124 +++++++++++---------- 2 files changed, 91 insertions(+), 77 deletions(-) diff --git a/src/WINNT/afsrdr/kernel/lib/AFSCreate.cpp b/src/WINNT/afsrdr/kernel/lib/AFSCreate.cpp index 93b92bc25..87415b3b5 100644 --- a/src/WINNT/afsrdr/kernel/lib/AFSCreate.cpp +++ b/src/WINNT/afsrdr/kernel/lib/AFSCreate.cpp @@ -454,33 +454,37 @@ AFSCommonCreate( IN PDEVICE_OBJECT DeviceObject, &pDirectoryCB, &uniComponentName); - // - // AFSLocateNameEntry returns pNewVolumeCB with a reference held - // even if pVolumeCB == pNewVolumeCB. It is always safe to release - // the reference on pVolumeCB that was held prior to the call. - // If pVolumeCB == pNewVolumeCB, the reference from AFSLocateNameEntry - // will be released second. - // + if ( pNewVolumeCB != NULL) + { - lCount = AFSVolumeDecrement( pVolumeCB, - VolumeReferenceReason); + // + // AFSLocateNameEntry returns pNewVolumeCB with a reference held + // even if pVolumeCB == pNewVolumeCB. It is always safe to release + // the reference on pVolumeCB that was held prior to the call. + // If pVolumeCB == pNewVolumeCB, the reference from AFSLocateNameEntry + // will be released second. + // - AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING, - AFS_TRACE_LEVEL_VERBOSE, - "AFSCommonCreate Decrement count on volume %p Reason %u Cnt %d\n", - pVolumeCB, - VolumeReferenceReason, - lCount); + lCount = AFSVolumeDecrement( pVolumeCB, + VolumeReferenceReason); - pVolumeCB = pNewVolumeCB; + AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING, + AFS_TRACE_LEVEL_VERBOSE, + "AFSCommonCreate Decrement count on volume %p Reason %u Cnt %d\n", + pVolumeCB, + VolumeReferenceReason, + lCount); - pNewVolumeCB = NULL; + pVolumeCB = pNewVolumeCB; - VolumeReferenceReason = NewVolumeReferenceReason; + pNewVolumeCB = NULL; - NewVolumeReferenceReason = AFS_VOLUME_REFERENCE_INVALID; + VolumeReferenceReason = NewVolumeReferenceReason; - bReleaseVolume = (pVolumeCB != NULL); + NewVolumeReferenceReason = AFS_VOLUME_REFERENCE_INVALID; + + bReleaseVolume = (pVolumeCB != NULL); + } // // AFSLocateNameEntry does not alter the reference count of diff --git a/src/WINNT/afsrdr/kernel/lib/AFSGeneric.cpp b/src/WINNT/afsrdr/kernel/lib/AFSGeneric.cpp index 0620b6a4c..505c70dca 100644 --- a/src/WINNT/afsrdr/kernel/lib/AFSGeneric.cpp +++ b/src/WINNT/afsrdr/kernel/lib/AFSGeneric.cpp @@ -6351,31 +6351,34 @@ AFSRetrieveFileAttributes( IN AFSDirectoryCB *ParentDirectoryCB, &pDirectoryEntry, NULL); - // - // AFSLocateNameEntry returns pNewVolumeCB with a reference held - // even if pVolumeCB == pNewVolumeCB. It is always safe to release - // the reference on pVolumeCB that was held prior to the call. - // If pVolumeCB == pNewVolumeCB, the reference from AFSLocateNameEntry - // will be released second. - // + if ( pNewVolumeCB != NULL) + { + // + // AFSLocateNameEntry returns pNewVolumeCB with a reference held + // even if pVolumeCB == pNewVolumeCB. It is always safe to release + // the reference on pVolumeCB that was held prior to the call. + // If pVolumeCB == pNewVolumeCB, the reference from AFSLocateNameEntry + // will be released second. + // - lCount = AFSVolumeDecrement( pVolumeCB, - VolumeReferenceReason); + lCount = AFSVolumeDecrement( pVolumeCB, + VolumeReferenceReason); - AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING, - AFS_TRACE_LEVEL_VERBOSE, - "AFSRetrieveFileAttributes Decrement count on volume %p Reason %u Cnt %d\n", - pVolumeCB, - VolumeReferenceReason, - lCount); + AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING, + AFS_TRACE_LEVEL_VERBOSE, + "AFSRetrieveFileAttributes Decrement count on volume %p Reason %u Cnt %d\n", + pVolumeCB, + VolumeReferenceReason, + lCount); - pVolumeCB = pNewVolumeCB; + pVolumeCB = pNewVolumeCB; - pNewVolumeCB = NULL; + pNewVolumeCB = NULL; - VolumeReferenceReason = NewVolumeReferenceReason; + VolumeReferenceReason = NewVolumeReferenceReason; - NewVolumeReferenceReason = AFS_VOLUME_REFERENCE_INVALID; + NewVolumeReferenceReason = AFS_VOLUME_REFERENCE_INVALID; + } // // AFSLocateNameEntry does not alter the reference count of @@ -7133,31 +7136,34 @@ AFSEvaluateRootEntry( IN AFSDirectoryCB *DirectoryCB, &pDirectoryEntry, NULL); - // - // AFSLocateNameEntry returns pNewVolumeCB with a reference held - // even if pVolumeCB == pNewVolumeCB. It is always safe to release - // the reference on pVolumeCB that was held prior to the call. - // If pVolumeCB == pNewVolumeCB, the reference from AFSLocateNameEntry - // will be released second. - // + if ( pNewVolumeCB != NULL) + { + // + // AFSLocateNameEntry returns pNewVolumeCB with a reference held + // even if pVolumeCB == pNewVolumeCB. It is always safe to release + // the reference on pVolumeCB that was held prior to the call. + // If pVolumeCB == pNewVolumeCB, the reference from AFSLocateNameEntry + // will be released second. + // - lCount = AFSVolumeDecrement( pVolumeCB, - VolumeReferenceReason); + lCount = AFSVolumeDecrement( pVolumeCB, + VolumeReferenceReason); - AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING, - AFS_TRACE_LEVEL_VERBOSE, - "AFSEvaluateRootEntry Decrement count on volume %p Reason %u Cnt %d\n", - pVolumeCB, - VolumeReferenceReason, - lCount); + AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING, + AFS_TRACE_LEVEL_VERBOSE, + "AFSEvaluateRootEntry Decrement count on volume %p Reason %u Cnt %d\n", + pVolumeCB, + VolumeReferenceReason, + lCount); - pVolumeCB = pNewVolumeCB; + pVolumeCB = pNewVolumeCB; - pNewVolumeCB = NULL; + pNewVolumeCB = NULL; - VolumeReferenceReason = NewVolumeReferenceReason; + VolumeReferenceReason = NewVolumeReferenceReason; - NewVolumeReferenceReason = AFS_VOLUME_REFERENCE_INVALID; + NewVolumeReferenceReason = AFS_VOLUME_REFERENCE_INVALID; + } // // AFSLocateNameEntry does not alter the reference count of @@ -8621,31 +8627,35 @@ AFSGetObjectStatus( IN AFSGetStatusInfoCB *GetStatusInfo, &pDirectoryEntry, NULL); - // - // AFSLocateNameEntry returns pNewVolumeCB with a reference held - // even if pVolumeCB == pNewVolumeCB. It is always safe to release - // the reference on pVolumeCB that was held prior to the call. - // If pVolumeCB == pNewVolumeCB, the reference from AFSLocateNameEntry - // will be released second. - // + if ( pNewVolumeCB != NULL) + { - lCount = AFSVolumeDecrement( pVolumeCB, - VolumeReferenceReason); + // + // AFSLocateNameEntry returns pNewVolumeCB with a reference held + // even if pVolumeCB == pNewVolumeCB. It is always safe to release + // the reference on pVolumeCB that was held prior to the call. + // If pVolumeCB == pNewVolumeCB, the reference from AFSLocateNameEntry + // will be released second. + // - AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING, - AFS_TRACE_LEVEL_VERBOSE, - "AFSGetObjectStatus Decrement count on volume %p Reason %u Cnt %d\n", - pVolumeCB, - VolumeReferenceReason, - lCount); + lCount = AFSVolumeDecrement( pVolumeCB, + VolumeReferenceReason); - pVolumeCB = pNewVolumeCB; + AFSDbgLogMsg( AFS_SUBSYSTEM_VOLUME_REF_COUNTING, + AFS_TRACE_LEVEL_VERBOSE, + "AFSGetObjectStatus Decrement count on volume %p Reason %u Cnt %d\n", + pVolumeCB, + VolumeReferenceReason, + lCount); - pNewVolumeCB = NULL; + pVolumeCB = pNewVolumeCB; - VolumeReferenceReason = NewVolumeReferenceReason; + pNewVolumeCB = NULL; - NewVolumeReferenceReason = AFS_VOLUME_REFERENCE_INVALID; + VolumeReferenceReason = NewVolumeReferenceReason; + + NewVolumeReferenceReason = AFS_VOLUME_REFERENCE_INVALID; + } // // AFSLocateNameEntry does not alter the reference count of -- 2.39.5