Commit 6af4bd0668 for qemu.org

commit 6af4bd0668628c6444d2ce7f616ce1c003daf49f
Author: Marc-André Lureau <marcandre.lureau@redhat.com>
Date:   Mon Sep 7 14:50:08 2026 +0400

    qga/vss-win32: guard CloseServiceHandle calls against NULL handles

    StopService() unconditionally calls CloseServiceHandle() on both
    the service and manager handles in the cleanup path, even when
    OpenSCManager() or OpenService() failed and the handles are NULL.

    Fixes: 917ebcb17027 ("qga-win: Fix QGA VSS Provider service stop failure")
    Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
    Reviewed-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
    Link: https://lore.kernel.org/qemu-devel/20260907-qga-v1-10-86456ad356e2@redhat.com
    Signed-off-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>

diff --git a/qga/vss-win32/install.cpp b/qga/vss-win32/install.cpp
index 12b045e207..9e8db79c12 100644
--- a/qga/vss-win32/install.cpp
+++ b/qga/vss-win32/install.cpp
@@ -597,8 +597,12 @@ STDAPI StopService(void)
     }

 out:
-    CloseServiceHandle(service);
-    CloseServiceHandle(manager);
+    if (service) {
+        CloseServiceHandle(service);
+    }
+    if (manager) {
+        CloseServiceHandle(manager);
+    }
     qga_debug_end;
     return hr;
 }