1b87cf
From ab4488be3282dd5d0b9582e6a5d1dafbe7b90489 Mon Sep 17 00:00:00 2001
1b87cf
Message-Id: <ab4488be3282dd5d0b9582e6a5d1dafbe7b90489@dist-git>
1b87cf
From: Peter Krempa <pkrempa@redhat.com>
1b87cf
Date: Tue, 25 Jan 2022 17:49:00 +0100
1b87cf
Subject: [PATCH] qemuDomainSetupDisk: Initialize 'targetPaths'
1b87cf
1b87cf
Compiler isn't able to see that 'virDevMapperGetTargets' in cases e.g.
1b87cf
when the devmapper isn't available may not initialize the value in the
1b87cf
pointer passed as the second argument.
1b87cf
1b87cf
The usage 'qemuDomainSetupDisk' lead to an accidental infinite loop as
1b87cf
previous calls apparently doctored the stack to a point where
1b87cf
'g_slist_concat' would end up in an infinite loop trying to find the end
1b87cf
of the list.
1b87cf
1b87cf
Fixes: 6c49c2ee9fcb88de02cdc333f666a8e95d60a3b0
1b87cf
Closes: https://gitlab.com/libvirt/libvirt/-/issues/268
1b87cf
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
1b87cf
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
1b87cf
(cherry picked from commit ddb2384f0c78a91c40d95afdbc7fe325e95ef2bc)
1b87cf
https://bugzilla.redhat.com/show_bug.cgi?id=2046172
1b87cf
---
1b87cf
 src/qemu/qemu_namespace.c | 2 +-
1b87cf
 1 file changed, 1 insertion(+), 1 deletion(-)
1b87cf
1b87cf
diff --git a/src/qemu/qemu_namespace.c b/src/qemu/qemu_namespace.c
1b87cf
index 23b1160c5e..94453033f5 100644
1b87cf
--- a/src/qemu/qemu_namespace.c
1b87cf
+++ b/src/qemu/qemu_namespace.c
1b87cf
@@ -251,7 +251,7 @@ qemuDomainSetupDisk(virStorageSource *src,
1b87cf
             if (!(tmpPath = virPCIDeviceAddressGetIOMMUGroupDev(&next->nvme->pciAddr)))
1b87cf
                 return -1;
1b87cf
         } else {
1b87cf
-            GSList *targetPaths;
1b87cf
+            GSList *targetPaths = NULL;
1b87cf
 
1b87cf
             if (virStorageSourceIsEmpty(next) ||
1b87cf
                 !virStorageSourceIsLocalStorage(next)) {
1b87cf
-- 
1b87cf
2.35.1
1b87cf