diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2022-09-05 12:17:45 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2022-09-18 09:17:40 +0200 |
commit | c4ef328bdc5dac319c8a1bdbe6d4108382b41584 (patch) | |
tree | 77e0cd4f717aac6eeec3bd6f87dbce1d4a4c4f2b | |
parent | 21adec30f62e4e700e0e217da756723e189d7b29 (diff) | |
download | qemu-c4ef328bdc5dac319c8a1bdbe6d4108382b41584.zip qemu-c4ef328bdc5dac319c8a1bdbe6d4108382b41584.tar.gz qemu-c4ef328bdc5dac319c8a1bdbe6d4108382b41584.tar.bz2 |
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 <pbonzini@redhat.com>
-rw-r--r-- | hw/ppc/spapr_pci.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 67e9d46..57c8a4f 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; |