]> xenbits.xensource.com Git - pvdrivers/win/xennet.git/commitdiff
Fix crash in co-installer
authorPaul Durrant <paul.durrant@citrix.com>
Mon, 25 Nov 2013 17:21:06 +0000 (17:21 +0000)
committerPaul Durrant <paul.durrant@citrix.com>
Mon, 25 Nov 2013 17:21:06 +0000 (17:21 +0000)
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
src/coinst/coinst.c

index 182a46d4c24faef26b5200556dd3d4a41bcf80c2..785675e46997a17edc05853e790da9e55a773a1f 100644 (file)
@@ -1127,6 +1127,8 @@ ClearAliasSoftwareKeyName(
     HKEY                    AliasesKey;
     HRESULT                 Error;
 
+    Log("====>");
+
     Location = GetProperty(DeviceInfoSet,
                            DeviceInfoData,
                            SPDRP_LOCATION_INFORMATION);
@@ -1154,6 +1156,8 @@ ClearAliasSoftwareKeyName(
 
     free(Location);
 
+    Log("<====");
+
     return TRUE;
 
 fail3:
@@ -1236,6 +1240,7 @@ GetInstallerSettingsKeyName(
 {
     PTCHAR                  Location;
     HKEY                    InstallerKey;
+    HKEY                    SubKey;
     HRESULT                 Error;
 
     Log("====>");
@@ -1247,6 +1252,8 @@ GetInstallerSettingsKeyName(
         goto fail1;
 
     *Name = NULL;
+    InstallerKey = NULL;
+    SubKey = NULL;
 
     Error = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
                          INSTALLER_KEY,
@@ -1261,6 +1268,19 @@ GetInstallerSettingsKeyName(
         goto fail2;
     }
 
+    Error = RegOpenKeyEx(InstallerKey,
+                         Location,
+                         0,
+                         KEY_READ,
+                         &SubKey);
+    if (Error != ERROR_SUCCESS) {
+        if (Error == ERROR_FILE_NOT_FOUND)
+            goto done;
+
+        SetLastError(Error);
+        goto fail3;
+    }
+
     *Name = Location;
 
     if (strlen(*Name) == 0) {
@@ -1268,15 +1288,24 @@ GetInstallerSettingsKeyName(
         *Name = NULL;
     }
 
-    RegCloseKey(InstallerKey);
-
 done:
+    if (SubKey != NULL)
+        RegCloseKey(SubKey);
+
+    if (InstallerKey != NULL)
+        RegCloseKey(InstallerKey);
+
     Log("%s", (*Name == NULL) ? "[NONE]" : *Name);
 
     Log("<====");
 
     return TRUE;
 
+fail3:
+    Log("fail3");
+
+    RegCloseKey(InstallerKey);
+
 fail2:
     Log("fail2");
 
@@ -2678,6 +2707,8 @@ DecrementServiceCount(
     DWORD       Type;
     HRESULT     Error;
 
+    Log("====>");
+
     Error = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
                          SERVICE_KEY(XENNET),
                          0,
@@ -2728,6 +2759,8 @@ DecrementServiceCount(
 
     RegCloseKey(ServiceKey);
 
+    Log("<====  ");
+
     return TRUE;
 
 fail5:
@@ -3056,10 +3089,18 @@ __DifRemovePreProcess(
             goto fail2;
     }
 
+    Success = ClearAliasSoftwareKeyName(DeviceInfoSet,
+                                        DeviceInfoData);
+    if (!Success)
+        goto fail3;
+
     Log("<====");
 
     return NO_ERROR;
 
+fail3:
+    Log("fail3");
+
 fail2:
     Log("fail2");
 
@@ -3096,14 +3137,9 @@ __DifRemovePostProcess(
         goto fail1;
     }
 
-    Success = ClearAliasSoftwareKeyName(DeviceInfoSet,
-                                        DeviceInfoData);
-    if (!Success)
-        goto fail2;
-
     Success = DecrementServiceCount(&Count);
     if (!Success)
-        goto fail3;
+        goto fail2;
 
     if (Count == 0)
         (VOID) RequestReboot(DeviceInfoSet, DeviceInfoData);
@@ -3112,9 +3148,6 @@ __DifRemovePostProcess(
 
     return NO_ERROR;
 
-fail3:
-    Log("fail3");
-
 fail2:
     Log("fail2");