Windows: AFSLocateNameEntry OutVolumeCB can be NULL
authorJeffrey Altman <jaltman@your-file-system.com>
Thu, 7 Mar 2013 22:28:36 +0000 (17:28 -0500)
committerJeffrey Altman <jaltman@your-file-system.com>
Mon, 11 Mar 2013 14:03:18 +0000 (07:03 -0700)
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 <buildbot@rampaginggeek.com>
Reviewed-by: Rod Widdowson <rdw@steadingsoftware.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>

src/WINNT/afsrdr/kernel/lib/AFSCreate.cpp
src/WINNT/afsrdr/kernel/lib/AFSGeneric.cpp

index 93b92bc..87415b3 100644 (file)
@@ -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
index 0620b6a..505c70d 100644 (file)
@@ -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