]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
qga: fix potentially not initialized nr_volumes in qga_vss_fsfreeze()
authorDenis V. Lunev <den@openvz.org>
Thu, 7 Aug 2025 13:32:21 +0000 (15:32 +0200)
committerKostiantyn Kostiuk <kkostiuk@redhat.com>
Mon, 1 Sep 2025 11:02:18 +0000 (14:02 +0300)
In this function we could have this variable not initialized. If this
could be acceptable on error, the variable could be left not initialized
f.e. as follows:

void requester_freeze(int *num_vols, void *mountpoints, ErrorSet *errset)
{
    ...
    if (mountpoints) {
        ...
        if (num_mount_points == 0) {
            /* If there is no valid mount points, just exit. */
            goto out;
        }
    }
    ...
    if (!mountpoints) {
        ...
        if (num_fixed_drives == 0) {
            goto out; /* If there is no fixed drive, just exit. */
        }
    }
    ...
}

Stay on safe side, initialize the variable at the beginning.

Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Kostiantyn Kostiuk <kkostiuk@redhat.com>
CC: Michael Roth <michael.roth@amd.com>
Reviewed-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20250807133221.1135453-1-den@openvz.org
Signed-off-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
qga/vss-win32.c

index f444a25a70e40382aca8e47f6be20d1a606e7c7d..b272bfc7829c4e241d156fe62a1ddd48b2a2a4d7 100644 (file)
@@ -157,6 +157,8 @@ void qga_vss_fsfreeze(int *nr_volume, bool freeze,
         .errp = errp,
     };
 
+    *nr_volume = 0;
+
     g_assert(errp);             /* requester.cpp requires it */
     func = (QGAVSSRequesterFunc)GetProcAddress(provider_lib, func_name);
     if (!func) {