]> www.infradead.org Git - users/dwmw2/qemu.git/commitdiff
qga-win: fix leaks of build_guest_disk_info()
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Sat, 3 Nov 2018 13:01:43 +0000 (17:01 +0400)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Fri, 9 Nov 2018 13:50:02 +0000 (07:50 -0600)
Introduced in commit b1ba8890e63ce9432c41c5c3fc229f54c87c9c99, vol_h
handle should be closed, and "out" cleanup should be done after
DeviceIoControl() fails.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
qga/commands-win32.c

index ef1d7d48d2df7224cc87c4c995d84e381e63b73b..62e1b51dfee7ac5fb1384e8198d0c48ba90d16dd 100644 (file)
@@ -797,7 +797,7 @@ static GuestDiskAddressList *build_guest_disk_info(char *guid, Error **errp)
                     0, extents, size, NULL, NULL)) {
                 error_setg_win32(errp, GetLastError(),
                     "failed to get disk extents");
-                return NULL;
+                goto out;
             }
         } else if (last_err == ERROR_INVALID_FUNCTION) {
             /* Possibly CD-ROM or a shared drive. Try to pass the volume */
@@ -855,6 +855,9 @@ static GuestDiskAddressList *build_guest_disk_info(char *guid, Error **errp)
 
 
 out:
+    if (vol_h != INVALID_HANDLE_VALUE) {
+        CloseHandle(vol_h);
+    }
     qapi_free_GuestDiskAddress(disk);
     g_free(extents);
     g_free(name);