Skip to contentSkip to conversation

qga: fix potentially not initialized nr_volumes in qga_vss_fsfreeze()

PATCH In review Denis V. Lunev via 2 participants 2 messages Aug 7, 2025 – Aug 11, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qga: fix potentially not initialized nr_volumes in qga_vss_fsfreeze()

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.

CC Kostiantyn Kostiuk <[email protected]>
CC Michael Roth <[email protected]>
---
 qga/vss-win32.c | 2 ++
 1 file changed, 2 insertions(+)
qga/vss-win32.c +2 -0
index f444a25a70..b272bfc782 100644
@@ -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) {
Signature · 1 line
2.45.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 51 lines · Denis V. Lunev via

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.

CC Kostiantyn Kostiuk <[email protected]>
CC Michael Roth <[email protected]>
---
 qga/vss-win32.c | 2 ++
 1 file changed, 2 insertions(+)
qga/vss-win32.c +2 -1
index f444a25a70..b272bfc782 100644
@@ -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) {
--

2.45.2