From: Paolo Bonzini Date: Mon, 5 Sep 2022 10:17:45 +0000 (+0200) Subject: spapr_pci: fix leak in spapr_phb_vfio_get_loc_code X-Git-Tag: v7.2.0-rc0~85^2~17 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c4ef328bdc5dac319c8a1bdbe6d4108382b41584;p=thirdparty%2Fqemu.git spapr_pci: fix leak in spapr_phb_vfio_get_loc_code 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 --- diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 67e9d468aa9..57c8a4f0855 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;