From 401dbfbce0b9acbc59f953d80461781afca4b0f7 Mon Sep 17 00:00:00 2001 From: tangbinzy Date: Wed, 4 Sep 2024 06:53:37 +0000 Subject: [PATCH] spapr_pci: fix leak in spapr_phb_vfio_get_loc_code mainline inclusion commit c4ef328bdc5dac319c8a1bdbe6d4108382b41584 category: bugfix --------------------------------------------------------------- Overwriting "path" in the second call to g_strdup_printf() causes a memory leak, even if the variable itself is g_autofree. Reported by Coverity as CID 1460454. Signed-off-by: Paolo Bonzini Signed-off-by: tangbinzy --- hw/ppc/spapr_pci.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 3b518f1be9..567bc8481c 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -800,6 +800,7 @@ static char *spapr_phb_vfio_get_loc_code(SpaprPhbState *sphb, PCIDevice *pdev) } /* Construct and read from host device tree the loc-code */ + g_free(path); path = g_strdup_printf("/proc/device-tree%s/ibm,loc-code", devspec); if (!g_file_get_contents(path, &buf, NULL, NULL)) { return NULL; -- 2.41.0.windows.1