]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
hw/ppc/pegasos: Fix memory leak
authorBALATON Zoltan <balaton@eik.bme.hu>
Sat, 1 Nov 2025 16:52:36 +0000 (17:52 +0100)
committerHarsh Prateek Bora <harshpb@linux.ibm.com>
Sun, 9 Nov 2025 11:24:44 +0000 (16:54 +0530)
Commit 9099b430a4 introduced an early return that caused a leak of a
GString. Allocate it later to avoid the leak.

Fixes: 9099b430a4 (hw/ppc/pegasos2: Change device tree generation)
Resolves: Coverity CID 1642027
Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Reported-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
Link: https://lore.kernel.org/r/20251101165236.76E8B5972E3@zero.eik.bme.hu
Message-ID: <20251101165236.76E8B5972E3@zero.eik.bme.hu>

hw/ppc/pegasos.c

index 3a498edd168ba24fcc81aec23e026229c85b85a5..8ce185de3eac35b78454218768a1f12a2950236a 100644 (file)
@@ -847,7 +847,7 @@ static struct {
 static void add_pci_device(PCIBus *bus, PCIDevice *d, void *opaque)
 {
     FDTInfo *fi = opaque;
-    GString *node = g_string_new(NULL);
+    GString *node;
     uint32_t cells[(PCI_NUM_REGIONS + 1) * 5];
     int i, j;
     const char *name = NULL;
@@ -871,6 +871,7 @@ static void add_pci_device(PCIBus *bus, PCIDevice *d, void *opaque)
             break;
         }
     }
+    node = g_string_new(NULL);
     g_string_printf(node, "%s/%s@%x", fi->path, (name ?: pn),
                     PCI_SLOT(d->devfn));
     if (PCI_FUNC(d->devfn)) {