[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL for-6.1 2/6] qga-win: Fix build_guest_fsinfo() close of nonexisten
From: |
Michael Roth |
Subject: |
[PULL for-6.1 2/6] qga-win: Fix build_guest_fsinfo() close of nonexistent |
Date: |
Tue, 3 Aug 2021 08:24:48 -0500 |
From: Basil Salman <basil@daynix.com>
On the current error path of build_guest_fsinfo(), a non existent handle
is passed to CloseHandle().
This patch adds initialization of hLocalDiskHandle to
INVALID_HANDLE_VALUE, and checks for handle validity before the handle
is closed.
Signed-off-by: Basil Salman <basil@daynix.com>
Signed-off-by: Basil Salman <basil@redhat.com>
Signed-off-by: Michael Roth <michael.roth@amd.com>
---
qga/commands-win32.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index a099acb34d..763186efd4 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -1091,7 +1091,7 @@ static GuestFilesystemInfo *build_guest_fsinfo(char
*guid, Error **errp)
size_t len;
uint64_t i64FreeBytesToCaller, i64TotalBytes, i64FreeBytes;
GuestFilesystemInfo *fs = NULL;
- HANDLE hLocalDiskHandle = NULL;
+ HANDLE hLocalDiskHandle = INVALID_HANDLE_VALUE;
GetVolumePathNamesForVolumeName(guid, (LPCH)&mnt, 0, &info_size);
if (GetLastError() != ERROR_MORE_DATA) {
@@ -1149,7 +1149,9 @@ static GuestFilesystemInfo *build_guest_fsinfo(char
*guid, Error **errp)
fs->type = g_strdup(fs_name);
fs->disk = build_guest_disk_info(guid, errp);
free:
- CloseHandle(hLocalDiskHandle);
+ if (hLocalDiskHandle != INVALID_HANDLE_VALUE) {
+ CloseHandle(hLocalDiskHandle);
+ }
g_free(mnt_point);
return fs;
}
--
2.25.1
- [PULL for-6.1 0/6] qemu-ga patch queue for hard-freeze, Michael Roth, 2021/08/03
- [PULL for-6.1 2/6] qga-win: Fix build_guest_fsinfo() close of nonexistent,
Michael Roth <=
- [PULL for-6.1 1/6] qga-win: Increase VSS freeze timeout to 60 secs instead of 10, Michael Roth, 2021/08/03
- [PULL for-6.1 4/6] qga-win: Free GMatchInfo properly, Michael Roth, 2021/08/03
- [PULL for-6.1 3/6] qga-win: Fix handle leak in ga_get_win_product_name(), Michael Roth, 2021/08/03
- [PULL for-6.1 5/6] qemu-ga/msi: fix w32 libgcc name, Michael Roth, 2021/08/03
- [PULL for-6.1 6/6] qga-win/msi: fix missing libstdc++-6 DLL in MSI installer, Michael Roth, 2021/08/03
- Re: [PULL for-6.1 0/6] qemu-ga patch queue for hard-freeze, Peter Maydell, 2021/08/03