aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2016-09-08 15:22:50 +0100
committerPeter Maydell <peter.maydell@linaro.org>2016-09-08 15:22:50 +0100
commit33e60e01988b02ac9baf4dc0f4a452b39fb5ce55 (patch)
tree39674954d438bcb4ed08b5cec4520deb0db88888
parent59351d9b40b1de0fb77e1ff3e53faa04c995c707 (diff)
parente2dd21e510ed66daeb4c5d58638450c1fb8c6fea (diff)
Merge remote-tracking branch 'remotes/elmarco/tags/leak-pull-request' into staging
Pull request v2: - dropped "tests: fix small leak in test-io-channel-command" that Daniel Berrange will pick - fixed "tests: add qtest_add_data_func_full" to work with glib < 2.26 # gpg: Signature made Thu 08 Sep 2016 15:16:54 BST # gpg: using RSA key 0xDAE8E10975969CE5 # gpg: Good signature from "Marc-André Lureau <marcandre.lureau@redhat.com>" # gpg: aka "Marc-André Lureau <marcandre.lureau@gmail.com>" # gpg: WARNING: This key is not certified with sufficiently trusted signatures! # gpg: It is not certain that the signature belongs to the owner. # Primary key fingerprint: 87A9 BD93 3F87 C606 D276 F62D DAE8 E109 7596 9CE5 * remotes/elmarco/tags/leak-pull-request: (25 commits) tests: fix postcopy-test leaks tests: fix rsp leak in postcopy-test tests: pc-cpu-test leaks fixes tests: add qtest_add_data_func_full bus: simplify name handling ipmi: free extern timer sd: free timer pc: keep gsi reference pc: free i8259 tests: fix qom-test leaks acpi-build: fix array leak machine: use class base init generated name pc: don't leak a20_line pc: simplify passing qemu_irq portio: keep references on portio tests: fix leak in test-string-input-visitor tests: fix check-qom-proplist leaks tests: fix check-qom-interface leaks tests: fix test-iov leaks tests: fix test-vmstate leaks ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r--hw/audio/gus.c9
-rw-r--r--hw/audio/sb16.c4
-rw-r--r--hw/block/fdc.c4
-rw-r--r--hw/char/parallel.c3
-rw-r--r--hw/core/bus.c21
-rw-r--r--hw/core/machine.c1
-rw-r--r--hw/display/vga-isa.c8
-rw-r--r--hw/dma/i8257.c6
-rw-r--r--hw/i386/acpi-build.c4
-rw-r--r--hw/i386/pc.c9
-rw-r--r--hw/i386/pc_piix.c17
-rw-r--r--hw/i386/pc_q35.c15
-rw-r--r--hw/ide/core.c6
-rw-r--r--hw/input/pckbd.c4
-rw-r--r--hw/ipmi/ipmi_bmc_extern.c9
-rw-r--r--hw/isa/isa-bus.c14
-rw-r--r--hw/sd/sd.c9
-rw-r--r--include/glib-compat.h24
-rw-r--r--include/hw/boards.h2
-rw-r--r--include/hw/i386/pc.h4
-rw-r--r--include/hw/ide/internal.h2
-rw-r--r--include/hw/isa/i8257.h2
-rw-r--r--include/hw/isa/isa.h5
-rw-r--r--include/hw/qdev-core.h2
-rw-r--r--qga/guest-agent-command-state.c6
-rw-r--r--qga/guest-agent-core.h1
-rw-r--r--qga/main.c13
-rw-r--r--tests/check-qom-interface.c1
-rw-r--r--tests/check-qom-proplist.c16
-rw-r--r--tests/libqtest.c19
-rw-r--r--tests/libqtest.h17
-rw-r--r--tests/pc-cpu-test.c24
-rw-r--r--tests/postcopy-test.c7
-rw-r--r--tests/qom-test.c5
-rw-r--r--tests/test-cutils.c24
-rw-r--r--tests/test-iov.c7
-rw-r--r--tests/test-qga.c5
-rw-r--r--tests/test-string-input-visitor.c1
-rw-r--r--tests/test-vmstate.c8
39 files changed, 248 insertions, 90 deletions
diff --git a/hw/audio/gus.c b/hw/audio/gus.c
index 6c02646773..3d08a6576a 100644
--- a/hw/audio/gus.c
+++ b/hw/audio/gus.c
@@ -60,6 +60,8 @@ typedef struct GUSState {
int64_t last_ticks;
qemu_irq pic;
IsaDma *isa_dma;
+ PortioList portio_list1;
+ PortioList portio_list2;
} GUSState;
static uint32_t gus_readb(void *opaque, uint32_t nport)
@@ -265,9 +267,10 @@ static void gus_realizefn (DeviceState *dev, Error **errp)
s->samples = AUD_get_buffer_size_out (s->voice) >> s->shift;
s->mixbuf = g_malloc0 (s->samples << s->shift);
- isa_register_portio_list (d, s->port, gus_portio_list1, s, "gus");
- isa_register_portio_list (d, (s->port + 0x100) & 0xf00,
- gus_portio_list2, s, "gus");
+ isa_register_portio_list(d, &s->portio_list1, s->port,
+ gus_portio_list1, s, "gus");
+ isa_register_portio_list(d, &s->portio_list2, (s->port + 0x100) & 0xf00,
+ gus_portio_list2, s, "gus");
s->isa_dma = isa_get_dma(isa_bus_from_device(d), s->emu.gusdma);
k = ISADMA_GET_CLASS(s->isa_dma);
diff --git a/hw/audio/sb16.c b/hw/audio/sb16.c
index 3a4a57ac31..6b4427f242 100644
--- a/hw/audio/sb16.c
+++ b/hw/audio/sb16.c
@@ -106,6 +106,7 @@ typedef struct SB16State {
/* mixer state */
int mixer_nreg;
uint8_t mixer_regs[256];
+ PortioList portio_list;
} SB16State;
static void SB_audio_callback (void *opaque, int free);
@@ -1378,7 +1379,8 @@ static void sb16_realizefn (DeviceState *dev, Error **errp)
dolog ("warning: Could not create auxiliary timer\n");
}
- isa_register_portio_list (isadev, s->port, sb16_ioport_list, s, "sb16");
+ isa_register_portio_list(isadev, &s->portio_list, s->port,
+ sb16_ioport_list, s, "sb16");
s->isa_hdma = isa_get_dma(isa_bus_from_device(isadev), s->hdma);
k = ISADMA_GET_CLASS(s->isa_hdma);
diff --git a/hw/block/fdc.c b/hw/block/fdc.c
index f73af7db46..b79873af27 100644
--- a/hw/block/fdc.c
+++ b/hw/block/fdc.c
@@ -692,6 +692,7 @@ struct FDCtrl {
/* Timers state */
uint8_t timer0;
uint8_t timer1;
+ PortioList portio_list;
};
static FloppyDriveType get_fallback_drive_type(FDrive *drv)
@@ -2495,7 +2496,8 @@ static void isabus_fdc_realize(DeviceState *dev, Error **errp)
FDCtrl *fdctrl = &isa->state;
Error *err = NULL;
- isa_register_portio_list(isadev, isa->iobase, fdc_portio_list, fdctrl,
+ isa_register_portio_list(isadev, &fdctrl->portio_list,
+ isa->iobase, fdc_portio_list, fdctrl,
"fdc");
isa_init_irq(isadev, &fdctrl->irq, isa->irq);
diff --git a/hw/char/parallel.c b/hw/char/parallel.c
index 11c78fed88..fa085667ff 100644
--- a/hw/char/parallel.c
+++ b/hw/char/parallel.c
@@ -80,6 +80,7 @@ typedef struct ParallelState {
uint32_t last_read_offset; /* For debugging */
/* Memory-mapped interface */
int it_shift;
+ PortioList portio_list;
} ParallelState;
#define TYPE_ISA_PARALLEL "isa-parallel"
@@ -532,7 +533,7 @@ static void parallel_isa_realizefn(DeviceState *dev, Error **errp)
s->status = dummy;
}
- isa_register_portio_list(isadev, base,
+ isa_register_portio_list(isadev, &s->portio_list, base,
(s->hw_driver
? &isa_parallel_portio_hw_list[0]
: &isa_parallel_portio_sw_list[0]),
diff --git a/hw/core/bus.c b/hw/core/bus.c
index 3e3f8ac740..cf383fc1af 100644
--- a/hw/core/bus.c
+++ b/hw/core/bus.c
@@ -78,8 +78,7 @@ static void qbus_realize(BusState *bus, DeviceState *parent, const char *name)
{
const char *typename = object_get_typename(OBJECT(bus));
BusClass *bc;
- char *buf;
- int i, len, bus_id;
+ int i, bus_id;
bus->parent = parent;
@@ -88,23 +87,15 @@ static void qbus_realize(BusState *bus, DeviceState *parent, const char *name)
} else if (bus->parent && bus->parent->id) {
/* parent device has id -> use it plus parent-bus-id for bus name */
bus_id = bus->parent->num_child_bus;
-
- len = strlen(bus->parent->id) + 16;
- buf = g_malloc(len);
- snprintf(buf, len, "%s.%d", bus->parent->id, bus_id);
- bus->name = buf;
+ bus->name = g_strdup_printf("%s.%d", bus->parent->id, bus_id);
} else {
/* no id -> use lowercase bus type plus global bus-id for bus name */
bc = BUS_GET_CLASS(bus);
bus_id = bc->automatic_ids++;
-
- len = strlen(typename) + 16;
- buf = g_malloc(len);
- len = snprintf(buf, len, "%s.%d", typename, bus_id);
- for (i = 0; i < len; i++) {
- buf[i] = qemu_tolower(buf[i]);
+ bus->name = g_strdup_printf("%s.%d", typename, bus_id);
+ for (i = 0; bus->name[i]; i++) {
+ bus->name[i] = qemu_tolower(bus->name[i]);
}
- bus->name = buf;
}
if (bus->parent) {
@@ -229,7 +220,7 @@ static void qbus_finalize(Object *obj)
{
BusState *bus = BUS(obj);
- g_free((char *)bus->name);
+ g_free(bus->name);
}
static const TypeInfo bus_info = {
diff --git a/hw/core/machine.c b/hw/core/machine.c
index e5a456f21d..00fbe3e880 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -561,6 +561,7 @@ static void machine_class_finalize(ObjectClass *klass, void *data)
if (mc->compat_props) {
g_array_free(mc->compat_props, true);
}
+ g_free(mc->name);
}
void machine_register_compat_props(MachineState *machine)
diff --git a/hw/display/vga-isa.c b/hw/display/vga-isa.c
index f5aff1cbe0..1af95562f2 100644
--- a/hw/display/vga-isa.c
+++ b/hw/display/vga-isa.c
@@ -39,6 +39,8 @@ typedef struct ISAVGAState {
ISADevice parent_obj;
struct VGACommonState state;
+ PortioList portio_vga;
+ PortioList portio_vbe;
} ISAVGAState;
static void vga_isa_reset(DeviceState *dev)
@@ -60,9 +62,11 @@ static void vga_isa_realizefn(DeviceState *dev, Error **errp)
vga_common_init(s, OBJECT(dev), true);
s->legacy_address_space = isa_address_space(isadev);
vga_io_memory = vga_init_io(s, OBJECT(dev), &vga_ports, &vbe_ports);
- isa_register_portio_list(isadev, 0x3b0, vga_ports, s, "vga");
+ isa_register_portio_list(isadev, &d->portio_vga,
+ 0x3b0, vga_ports, s, "vga");
if (vbe_ports) {
- isa_register_portio_list(isadev, 0x1ce, vbe_ports, s, "vbe");
+ isa_register_portio_list(isadev, &d->portio_vbe,
+ 0x1ce, vbe_ports, s, "vbe");
}
memory_region_add_subregion_overlap(isa_address_space(isadev),
0x000a0000,
diff --git a/hw/dma/i8257.c b/hw/dma/i8257.c
index f345c54762..bffbdea0ca 100644
--- a/hw/dma/i8257.c
+++ b/hw/dma/i8257.c
@@ -553,10 +553,12 @@ static void i8257_realize(DeviceState *dev, Error **errp)
memory_region_add_subregion(isa_address_space_io(isa),
d->base, &d->channel_io);
- isa_register_portio_list(isa, d->page_base, page_portio_list, d,
+ isa_register_portio_list(isa, &d->portio_page,
+ d->page_base, page_portio_list, d,
"dma-page");
if (d->pageh_base >= 0) {
- isa_register_portio_list(isa, d->pageh_base, pageh_portio_list, d,
+ isa_register_portio_list(isa, &d->portio_pageh,
+ d->pageh_base, pageh_portio_list, d,
"dma-pageh");
}
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index a26a4bb03f..433febafdd 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -789,7 +789,7 @@ static gint crs_range_compare(gconstpointer a, gconstpointer b)
static void crs_replace_with_free_ranges(GPtrArray *ranges,
uint64_t start, uint64_t end)
{
- GPtrArray *free_ranges = g_ptr_array_new_with_free_func(crs_range_free);
+ GPtrArray *free_ranges = g_ptr_array_new();
uint64_t free_base = start;
int i;
@@ -813,7 +813,7 @@ static void crs_replace_with_free_ranges(GPtrArray *ranges,
g_ptr_array_add(ranges, g_ptr_array_index(free_ranges, i));
}
- g_ptr_array_free(free_ranges, false);
+ g_ptr_array_free(free_ranges, true);
}
/*
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 022dd1b205..e31f70f428 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -530,9 +530,9 @@ static uint64_t port92_read(void *opaque, hwaddr addr,
return ret;
}
-static void port92_init(ISADevice *dev, qemu_irq *a20_out)
+static void port92_init(ISADevice *dev, qemu_irq a20_out)
{
- qdev_connect_gpio_out_named(DEVICE(dev), PORT92_A20_LINE, 0, *a20_out);
+ qdev_connect_gpio_out_named(DEVICE(dev), PORT92_A20_LINE, 0, a20_out);
}
static const VMStateDescription vmstate_port92_isa = {
@@ -1594,7 +1594,7 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
a20_line = qemu_allocate_irqs(handle_a20_line_change, first_cpu, 2);
i8042 = isa_create_simple(isa_bus, "i8042");
- i8042_setup_a20_line(i8042, &a20_line[0]);
+ i8042_setup_a20_line(i8042, a20_line[0]);
if (!no_vmport) {
vmport_init(isa_bus);
vmmouse = isa_try_create(isa_bus, "vmmouse");
@@ -1607,7 +1607,8 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
qdev_init_nofail(dev);
}
port92 = isa_create_simple(isa_bus, "port92");
- port92_init(port92, &a20_line[1]);
+ port92_init(port92, a20_line[1]);
+ g_free(a20_line);
DMA_init(isa_bus, 0);
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index a07dc816bf..2af8888f0a 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -74,7 +74,6 @@ static void pc_init1(MachineState *machine,
ISABus *isa_bus;
PCII440FXState *i440fx_state;
int piix3_devfn = -1;
- qemu_irq *gsi;
qemu_irq *i8259;
qemu_irq smi_irq;
GSIState *gsi_state;
@@ -185,16 +184,16 @@ static void pc_init1(MachineState *machine,
gsi_state = g_malloc0(sizeof(*gsi_state));
if (kvm_ioapic_in_kernel()) {
kvm_pc_setup_irq_routing(pcmc->pci_enabled);
- gsi = qemu_allocate_irqs(kvm_pc_gsi_handler, gsi_state,
- GSI_NUM_PINS);
+ pcms->gsi = qemu_allocate_irqs(kvm_pc_gsi_handler, gsi_state,
+ GSI_NUM_PINS);
} else {
- gsi = qemu_allocate_irqs(gsi_handler, gsi_state, GSI_NUM_PINS);
+ pcms->gsi = qemu_allocate_irqs(gsi_handler, gsi_state, GSI_NUM_PINS);
}
if (pcmc->pci_enabled) {
pci_bus = i440fx_init(host_type,
pci_type,
- &i440fx_state, &piix3_devfn, &isa_bus, gsi,
+ &i440fx_state, &piix3_devfn, &isa_bus, pcms->gsi,
system_memory, system_io, machine->ram_size,
pcms->below_4g_mem_size,
pcms->above_4g_mem_size,
@@ -207,7 +206,7 @@ static void pc_init1(MachineState *machine,
&error_abort);
no_hpet = 1;
}
- isa_bus_irqs(isa_bus, gsi);
+ isa_bus_irqs(isa_bus, pcms->gsi);
if (kvm_pic_in_kernel()) {
i8259 = kvm_i8259_init(isa_bus);
@@ -225,7 +224,7 @@ static void pc_init1(MachineState *machine,
ioapic_init_gsi(gsi_state, "i440fx");
}
- pc_register_ferr_irq(gsi[13]);
+ pc_register_ferr_irq(pcms->gsi[13]);
pc_vga_init(isa_bus, pcmc->pci_enabled ? pci_bus : NULL);
@@ -235,7 +234,7 @@ static void pc_init1(MachineState *machine,
}
/* init basic PC hardware */
- pc_basic_device_init(isa_bus, gsi, &rtc_state, true,
+ pc_basic_device_init(isa_bus, pcms->gsi, &rtc_state, true,
(pcms->vmport != ON_OFF_AUTO_ON), 0x4);
pc_nic_init(isa_bus, pci_bus);
@@ -279,7 +278,7 @@ static void pc_init1(MachineState *machine,
smi_irq = qemu_allocate_irq(pc_acpi_smi_interrupt, first_cpu, 0);
/* TODO: Populate SPD eeprom data. */
smbus = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100,
- gsi[9], smi_irq,
+ pcms->gsi[9], smi_irq,
pc_machine_is_smm_enabled(pcms),
&piix4_pm);
smbus_eeprom_init(smbus, 8, NULL, 0);
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index c0b9961928..3cbcbb0c7e 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -69,7 +69,6 @@ static void pc_q35_init(MachineState *machine)
MemoryRegion *ram_memory;
GSIState *gsi_state;
ISABus *isa_bus;
- qemu_irq *gsi;
qemu_irq *i8259;
int i;
ICH9LPCState *ich9_lpc;
@@ -153,10 +152,10 @@ static void pc_q35_init(MachineState *machine)
gsi_state = g_malloc0(sizeof(*gsi_state));
if (kvm_ioapic_in_kernel()) {
kvm_pc_setup_irq_routing(pcmc->pci_enabled);
- gsi = qemu_allocate_irqs(kvm_pc_gsi_handler, gsi_state,
- GSI_NUM_PINS);
+ pcms->gsi = qemu_allocate_irqs(kvm_pc_gsi_handler, gsi_state,
+ GSI_NUM_PINS);
} else {
- gsi = qemu_allocate_irqs(gsi_handler, gsi_state, GSI_NUM_PINS);
+ pcms->gsi = qemu_allocate_irqs(gsi_handler, gsi_state, GSI_NUM_PINS);
}
/* create pci host bus */
@@ -195,7 +194,7 @@ static void pc_q35_init(MachineState *machine)
ich9_lpc = ICH9_LPC_DEVICE(lpc);
lpc_dev = DEVICE(lpc);
for (i = 0; i < GSI_NUM_PINS; i++) {
- qdev_connect_gpio_out_named(lpc_dev, ICH9_GPIO_GSI, i, gsi[i]);
+ qdev_connect_gpio_out_named(lpc_dev, ICH9_GPIO_GSI, i, pcms->gsi[i]);
}
pci_bus_irqs(host_bus, ich9_lpc_set_irq, ich9_lpc_map_irq, ich9_lpc,
ICH9_LPC_NB_PIRQS);
@@ -213,11 +212,13 @@ static void pc_q35_init(MachineState *machine)
for (i = 0; i < ISA_NUM_IRQS; i++) {
gsi_state->i8259_irq[i] = i8259[i];
}
+ g_free(i8259);
+
if (pcmc->pci_enabled) {
ioapic_init_gsi(gsi_state, "q35");
}
- pc_register_ferr_irq(gsi[13]);
+ pc_register_ferr_irq(pcms->gsi[13]);
assert(pcms->vmport != ON_OFF_AUTO__MAX);
if (pcms->vmport == ON_OFF_AUTO_AUTO) {
@@ -225,7 +226,7 @@ static void pc_q35_init(MachineState *machine)
}
/* init basic PC hardware */
- pc_basic_device_init(isa_bus, gsi, &rtc_state, !mc->no_floppy,
+ pc_basic_device_init(isa_bus, pcms->gsi, &rtc_state, !mc->no_floppy,
(pcms->vmport != ON_OFF_AUTO_ON), 0xff0104);
/* connect pm stuff to lpc */
diff --git a/hw/ide/core.c b/hw/ide/core.c
index 45b6df132c..b0e42a6562 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -2619,10 +2619,12 @@ void ide_init_ioport(IDEBus *bus, ISADevice *dev, int iobase, int iobase2)
{
/* ??? Assume only ISA and PCI configurations, and that the PCI-ISA
bridge has been setup properly to always register with ISA. */
- isa_register_portio_list(dev, iobase, ide_portio_list, bus, "ide");
+ isa_register_portio_list(dev, &bus->portio_list,
+ iobase, ide_portio_list, bus, "ide");
if (iobase2) {
- isa_register_portio_list(dev, iobase2, ide_portio2_list, bus, "ide");
+ isa_register_portio_list(dev, &bus->portio2_list,
+ iobase2, ide_portio2_list, bus, "ide");
}
}
diff --git a/hw/input/pckbd.c b/hw/input/pckbd.c
index dc57e2c762..d414288839 100644
--- a/hw/input/pckbd.c
+++ b/hw/input/pckbd.c
@@ -499,9 +499,9 @@ void i8042_isa_mouse_fake_event(void *opaque)
ps2_mouse_fake_event(s->mouse);
}
-void i8042_setup_a20_line(ISADevice *dev, qemu_irq *a20_out)
+void i8042_setup_a20_line(ISADevice *dev, qemu_irq a20_out)
{
- qdev_connect_gpio_out_named(DEVICE(dev), I8042_A20_LINE, 0, *a20_out);
+ qdev_connect_gpio_out_named(DEVICE(dev), I8042_A20_LINE, 0, a20_out);
}
static const VMStateDescription vmstate_kbd_isa = {
diff --git a/hw/ipmi/ipmi_bmc_extern.c b/hw/ipmi/ipmi_bmc_extern.c
index 157879e177..5b73983e7d 100644
--- a/hw/ipmi/ipmi_bmc_extern.c
+++ b/hw/ipmi/ipmi_bmc_extern.c
@@ -487,6 +487,14 @@ static void ipmi_bmc_extern_init(Object *obj)
vmstate_register(NULL, 0, &vmstate_ipmi_bmc_extern, ibe);
}
+static void ipmi_bmc_extern_finalize(Object *obj)
+{
+ IPMIBmcExtern *ibe = IPMI_BMC_EXTERN(obj);
+
+ timer_del(ibe->extern_timer);
+ timer_free(ibe->extern_timer);
+}
+
static Property ipmi_bmc_extern_properties[] = {
DEFINE_PROP_CHR("chardev", IPMIBmcExtern, chr),
DEFINE_PROP_END_OF_LIST(),
@@ -508,6 +516,7 @@ static const TypeInfo ipmi_bmc_extern_type = {
.parent = TYPE_IPMI_BMC,
.instance_size = sizeof(IPMIBmcExtern),
.instance_init = ipmi_bmc_extern_init,
+ .instance_finalize = ipmi_bmc_extern_finalize,
.class_init = ipmi_bmc_extern_class_init,
};
diff --git a/hw/isa/isa-bus.c b/hw/isa/isa-bus.c
index ce74db232a..9d07b118c0 100644
--- a/hw/isa/isa-bus.c
+++ b/hw/isa/isa-bus.c
@@ -131,24 +131,20 @@ void isa_register_ioport(ISADevice *dev, MemoryRegion *io, uint16_t start)
isa_init_ioport(dev, start);
}
-void isa_register_portio_list(ISADevice *dev, uint16_t start,
+void isa_register_portio_list(ISADevice *dev,
+ PortioList *piolist, uint16_t start,
const MemoryRegionPortio *pio_start,
void *opaque, const char *name)
{
- PortioList piolist;
+ assert(piolist && !piolist->owner);
/* START is how we should treat DEV, regardless of the actual
contents of the portio array. This is how the old code
actually handled e.g. the FDC device. */
isa_init_ioport(dev, start);
- /* FIXME: the device should store created PortioList in its state. Note
- that DEV can be NULL here and that single device can register several
- portio lists. Current implementation is leaking memory allocated
- in portio_list_init. The leak is not critical because it happens only
- at initialization time. */
- portio_list_init(&piolist, OBJECT(dev), pio_start, opaque, name);
- portio_list_add(&piolist, isabus->address_space_io, start);
+ portio_list_init(piolist, OBJECT(dev), pio_start, opaque, name);
+ portio_list_add(piolist, isabus->address_space_io, start);
}
static void isa_device_init(Object *obj)
diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index 87c6dc108d..8e88e8311a 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -1876,6 +1876,14 @@ static void sd_instance_init(Object *obj)
sd->ocr_power_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, sd_ocr_powerup, sd);
}
+static void sd_instance_finalize(Object *obj)
+{
+ SDState *sd = SD_CARD(obj);
+
+ timer_del(sd->ocr_power_timer);
+ timer_free(sd->ocr_power_timer);
+}
+
static void sd_realize(DeviceState *dev, Error **errp)
{
SDState *sd = SD_CARD(dev);
@@ -1927,6 +1935,7 @@ static const TypeInfo sd_info = {
.class_size = sizeof(SDCardClass),
.class_init = sd_class_init,
.instance_init = sd_instance_init,
+ .instance_finalize = sd_instance_finalize,
};
static void sd_register_types(void)
diff --git a/include/glib-compat.h b/include/glib-compat.h
index 8d5a7f3801..8093163bee 100644
--- a/include/glib-compat.h
+++ b/include/glib-compat.h
@@ -280,4 +280,28 @@ static inline void g_hash_table_add(GHashTable *hash_table, gpointer key)
} while (0)
#endif
+#if !GLIB_CHECK_VERSION(2, 28, 0)
+static inline void g_list_free_full(GList *list, GDestroyNotify free_func)
+{
+ GList *l;
+
+ for (l = list; l; l = l->next) {
+ free_func(l->data);
+ }
+
+ g_list_free(list);
+}
+
+static inline void g_slist_free_full(GSList *list, GDestroyNotify free_func)
+{
+ GSList *l;
+
+ for (l = list; l; l = l->next) {
+ free_func(l->data);
+ }
+
+ g_slist_free(list);
+}
+#endif
+
#endif
diff --git a/include/hw/boards.h b/include/hw/boards.h
index 3e69eca038..e46a744bcd 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -93,7 +93,7 @@ struct MachineClass {
/*< public >*/
const char *family; /* NULL iff @name identifies a standalone machtype */
- const char *name;
+ char *name;
const char *alias;
const char *desc;
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 74c175c1e5..c4316c30a8 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -53,6 +53,7 @@ struct PCMachineState {
ISADevice *rtc;
PCIBus *bus;
FWCfgState *fw_cfg;
+ qemu_irq *gsi;
/* Configuration options: */
uint64_t max_ram_below_4g;
@@ -220,7 +221,7 @@ void i8042_mm_init(qemu_irq kbd_irq, qemu_irq mouse_irq,
MemoryRegion *region, ram_addr_t size,
hwaddr mask);
void i8042_isa_mouse_fake_event(void *opaque);
-void i8042_setup_a20_line(ISADevice *dev, qemu_irq *a20_out);
+void i8042_setup_a20_line(ISADevice *dev, qemu_irq a20_out);
/* pc.c */
extern int fd_bootchk;
@@ -903,7 +904,6 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
{ \
MachineClass *mc = MACHINE_CLASS(oc); \
optsfn(mc); \
- mc->name = namestr; \
mc->init = initfn; \
} \
static const TypeInfo pc_machine_type_##suffix = { \
diff --git a/include/hw/ide/internal.h b/include/hw/ide/internal.h
index 7824bc34ce..a6dd2c3d30 100644
--- a/include/hw/ide/internal.h
+++ b/include/hw/ide/internal.h
@@ -480,6 +480,8 @@ struct IDEBus {
uint8_t retry_unit;
int64_t retry_sector_num;
uint32_t retry_nsector;
+ PortioList portio_list;
+ PortioList portio2_list;
};
#define TYPE_IDE_DEVICE "ide-device"
diff --git a/include/hw/isa/i8257.h b/include/hw/isa/i8257.h
index aa211c0df7..88a2766a3f 100644
--- a/include/hw/isa/i8257.h
+++ b/include/hw/isa/i8257.h
@@ -36,6 +36,8 @@ typedef struct I8257State {
QEMUBH *dma_bh;
bool dma_bh_scheduled;
int running;
+ PortioList portio_page;
+ PortioList portio_pageh;
} I8257State;
#endif
diff --git a/include/hw/isa/isa.h b/include/hw/isa/isa.h
index 7693ac5454..c2fdd70cdc 100644
--- a/include/hw/isa/isa.h
+++ b/include/hw/isa/isa.h
@@ -134,12 +134,15 @@ void isa_register_ioport(ISADevice *dev, MemoryRegion *io, uint16_t start);
* device and use the legacy portio routines.
*
* @dev: the ISADevice against which these are registered; may be NULL.
+ * @piolist: the PortioList associated with the io ports
* @start: the base I/O port against which the portio->offset is applied.
* @portio: the ports, sorted by offset.
* @opaque: passed into the portio callbacks.
* @name: passed into memory_region_init_io.
*/
-void isa_register_portio_list(ISADevice *dev, uint16_t start,
+void isa_register_portio_list(ISADevice *dev,
+ PortioList *piolist,
+ uint16_t start,
const MemoryRegionPortio *portio,
void *opaque, const char *name);
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index 4b4b33bec8..2c973473f7 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -224,7 +224,7 @@ typedef struct BusChild {
struct BusState {
Object obj;
DeviceState *parent;
- const char *name;
+ char *name;
HotplugHandler *hotplug_handler;
int max_index;
bool realized;
diff --git a/qga/guest-agent-command-state.c b/qga/guest-agent-command-state.c
index 4de229cd78..e609d320f0 100644
--- a/qga/guest-agent-command-state.c
+++ b/qga/guest-agent-command-state.c
@@ -71,3 +71,9 @@ GACommandState *ga_command_state_new(void)
cs->groups = NULL;
return cs;
}
+
+void ga_command_state_free(GACommandState *cs)
+{
+ g_slist_free_full(cs->groups, g_free);
+ g_free(cs);
+}
diff --git a/qga/guest-agent-core.h b/qga/guest-agent-core.h
index 0a49516045..63e9d398ae 100644
--- a/qga/guest-agent-core.h
+++ b/qga/guest-agent-core.h
@@ -28,6 +28,7 @@ void ga_command_state_add(GACommandState *cs,
void ga_command_state_init_all(GACommandState *cs);
void ga_command_state_cleanup_all(GACommandState *cs);
GACommandState *ga_command_state_new(void);
+void ga_command_state_free(GACommandState *cs);
bool ga_logging_enabled(GAState *s);
void ga_disable_logging(GAState *s);
void ga_enable_logging(GAState *s);
diff --git a/qga/main.c b/qga/main.c
index 4c3b2c772b..0b9d04ea04 100644
--- a/qga/main.c
+++ b/qga/main.c
@@ -1175,6 +1175,7 @@ static void config_free(GAConfig *config)
#ifdef CONFIG_FSFREEZE
g_free(config->fsfreeze_hook);
#endif
+ g_list_free_full(config->blacklist, g_free);
g_free(config);
}
@@ -1310,11 +1311,6 @@ static int run_agent(GAState *s, GAConfig *config)
return EXIT_SUCCESS;
}
-static void free_blacklist_entry(gpointer entry, gpointer unused)
-{
- g_free(entry);
-}
-
int main(int argc, char **argv)
{
int ret = EXIT_SUCCESS;
@@ -1375,11 +1371,12 @@ int main(int argc, char **argv)
end:
if (s->command_state) {
ga_command_state_cleanup_all(s->command_state);
+ ga_command_state_free(s->command_state);
+ json_message_parser_destroy(&s->parser);
}
if (s->channel) {
ga_channel_free(s->channel);
}
- g_list_foreach(config->blacklist, free_blacklist_entry, NULL);
g_free(s->pstate_filepath);
g_free(s->state_filepath_isfrozen);
@@ -1388,6 +1385,10 @@ end:
}
config_free(config);
+ if (s->main_loop) {
+ g_main_loop_unref(s->main_loop);
+ }
+ g_free(s);
return ret;
}
diff --git a/tests/check-qom-interface.c b/tests/check-qom-interface.c
index 719ddcf2e0..f87c9aaa8a 100644
--- a/tests/check-qom-interface.c
+++ b/tests/check-qom-interface.c
@@ -76,6 +76,7 @@ static void test_interface_impl(const char *type)
g_assert(iobj);
g_assert(ioc->test == PATTERN);
+ object_unref(obj);
}
static void interface_direct_test(void)
diff --git a/tests/check-qom-proplist.c b/tests/check-qom-proplist.c
index 42defe7128..a16cefca73 100644
--- a/tests/check-qom-proplist.c
+++ b/tests/check-qom-proplist.c
@@ -230,6 +230,13 @@ struct DummyBackendClass {
};
+static void dummy_dev_finalize(Object *obj)
+{
+ DummyDev *dev = DUMMY_DEV(obj);
+
+ object_unref(OBJECT(dev->bus));
+}
+
static void dummy_dev_init(Object *obj)
{
DummyDev *dev = DUMMY_DEV(obj);
@@ -257,6 +264,13 @@ static void dummy_dev_class_init(ObjectClass *klass, void *opaque)
}
+static void dummy_bus_finalize(Object *obj)
+{
+ DummyBus *bus = DUMMY_BUS(obj);
+
+ object_unref(OBJECT(bus->backend));
+}
+
static void dummy_bus_init(Object *obj)
{
}
@@ -283,6 +297,7 @@ static const TypeInfo dummy_dev_info = {
.parent = TYPE_OBJECT,
.instance_size = sizeof(DummyDev),
.instance_init = dummy_dev_init,
+ .instance_finalize = dummy_dev_finalize,
.class_size = sizeof(DummyDevClass),
.class_init = dummy_dev_class_init,
};
@@ -292,6 +307,7 @@ static const TypeInfo dummy_bus_info = {
.parent = TYPE_OBJECT,
.instance_size = sizeof(DummyBus),
.instance_init = dummy_bus_init,
+ .instance_finalize = dummy_bus_finalize,
.class_size = sizeof(DummyBusClass),
.class_init = dummy_bus_class_init,
};
diff --git a/tests/libqtest.c b/tests/libqtest.c
index eb00f1392b..42ccb62f80 100644
--- a/tests/libqtest.c
+++ b/tests/libqtest.c
@@ -758,6 +758,25 @@ void qtest_add_func(const char *str, void (*fn)(void))
g_free(path);
}
+void qtest_add_data_func_full(const char *str, void *data,
+ void (*fn)(const void *),
+ GDestroyNotify data_free_func)
+{
+ gchar *path = g_strdup_printf("/%s/%s", qtest_get_arch(), str);
+#if GLIB_CHECK_VERSION(2, 34, 0)
+ g_test_add_data_func_full(path, data, fn, data_free_func);
+#elif GLIB_CHECK_VERSION(2, 26, 0)
+ /* back-compat casts, remove this once we can require new-enough glib */
+ g_test_add_vtable(path, 0, data, NULL,
+ (GTestFixtureFunc)fn, (GTestFixtureFunc) data_free_func);
+#else
+ /* back-compat casts, remove this once we can require new-enough glib */
+ g_test_add_vtable(path, 0, data, NULL,
+ (void (*)(void)) fn, (void (*)(void)) data_free_func);
+#endif
+ g_free(path);
+}
+
void qtest_add_data_func(const char *str, const void *data,
void (*fn)(const void *))
{
diff --git a/tests/libqtest.h b/tests/libqtest.h
index 37f37adbf7..d2b48535a6 100644
--- a/tests/libqtest.h
+++ b/tests/libqtest.h
@@ -426,6 +426,23 @@ void qtest_add_data_func(const char *str, const void *data,
void (*fn)(const void *));
/**
+ * qtest_add_data_func_full:
+ * @str: Test case path.
+ * @data: Test case data
+ * @fn: Test case function
+ * @data_free_func: GDestroyNotify for data
+ *
+ * Add a GTester testcase with the given name, data and function.
+ * The path is prefixed with the architecture under test, as
+ * returned by qtest_get_arch().
+ *
+ * @data is passed to @data_free_func() on test completion.
+ */
+void qtest_add_data_func_full(const char *str, void *data,
+ void (*fn)(const void *),
+ GDestroyNotify data_free_func);
+
+/**
* qtest_add:
* @testpath: Test case path
* @Fixture: Fixture type
diff --git a/tests/pc-cpu-test.c b/tests/pc-cpu-test.c
index 4428cea5f1..c3a2633d3c 100644
--- a/tests/pc-cpu-test.c
+++ b/tests/pc-cpu-test.c
@@ -14,7 +14,7 @@
#include "qapi/qmp/types.h"
struct PCTestData {
- const char *machine;
+ char *machine;
const char *cpu_model;
unsigned sockets;
unsigned cores;
@@ -71,6 +71,14 @@ static void test_pc_without_cpu_add(gconstpointer data)
g_free(args);
}
+static void test_data_free(gpointer data)
+{
+ PCTestData *pc = data;
+
+ g_free(pc->machine);
+ g_free(pc);
+}
+
static void add_pc_test_cases(void)
{
QDict *response, *minfo;
@@ -78,7 +86,8 @@ static void add_pc_test_cases(void)
const QListEntry *p;
QObject *qobj;
QString *qstr;
- const char *mname, *path;
+ const char *mname;
+ char *path;
PCTestData *data;
qtest_start("-machine none");
@@ -99,7 +108,7 @@ static void add_pc_test_cases(void)
continue;
}
data = g_malloc(sizeof(PCTestData));
- data->machine = mname;
+ data->machine = g_strdup(mname);
data->cpu_model = "Haswell"; /* 1.3+ theoretically */
data->sockets = 1;
data->cores = 3;
@@ -119,14 +128,19 @@ static void add_pc_test_cases(void)
path = g_strdup_printf("cpu/%s/init/%ux%ux%u&maxcpus=%u",
mname, data->sockets, data->cores,
data->threads, data->maxcpus);
- qtest_add_data_func(path, data, test_pc_without_cpu_add);
+ qtest_add_data_func_full(path, data, test_pc_without_cpu_add,
+ test_data_free);
+ g_free(path);
} else {
path = g_strdup_printf("cpu/%s/add/%ux%ux%u&maxcpus=%u",
mname, data->sockets, data->cores,
data->threads, data->maxcpus);
- qtest_add_data_func(path, data, test_pc_with_cpu_add);
+ qtest_add_data_func_full(path, data, test_pc_with_cpu_add,
+ test_data_free);
+ g_free(path);
}
}
+ QDECREF(response);
qtest_end();
}
diff --git a/tests/postcopy-test.c b/tests/postcopy-test.c
index 229e9e901a..41ed1a976f 100644
--- a/tests/postcopy-test.c
+++ b/tests/postcopy-test.c
@@ -176,6 +176,7 @@ static void wait_for_serial(const char *side)
int started = (strcmp(side, "src_serial") == 0 &&
strcmp(arch, "ppc64") == 0) ? 0 : 1;
+ g_free(serialpath);
do {
int readvalue = fgetc(serialfile);
@@ -203,7 +204,6 @@ static void wait_for_serial(const char *side)
case 'B':
/* It's alive! */
fclose(serialfile);
- g_free(serialpath);
return;
case EOF:
@@ -260,8 +260,8 @@ static uint64_t get_migration_pass(void)
} else {
rsp_ram = qdict_get_qdict(rsp_return, "ram");
result = qdict_get_try_int(rsp_ram, "dirty-sync-count", 0);
- QDECREF(rsp);
}
+ QDECREF(rsp);
return result;
}
@@ -350,6 +350,7 @@ static void cleanup(const char *filename)
char *path = g_strdup_printf("%s/%s", tmpfs, filename);
unlink(path);
+ g_free(path);
}
static void test_migrate(void)
@@ -394,6 +395,8 @@ static void test_migrate(void)
g_assert_not_reached();
}
+ g_free(bootpath);
+
from = qtest_start(cmd_src);
g_free(cmd_src);
diff --git a/tests/qom-test.c b/tests/qom-test.c
index 23493a2b0a..d48f890e84 100644
--- a/tests/qom-test.c
+++ b/tests/qom-test.c
@@ -115,7 +115,7 @@ static void add_machine_test_cases(void)
const QListEntry *p;
QObject *qobj;
QString *qstr;
- const char *mname, *path;
+ const char *mname;
qtest_start("-machine none");
response = qmp("{ 'execute': 'query-machines' }");
@@ -132,8 +132,9 @@ static void add_machine_test_cases(void)
g_assert(qstr);
mname = qstring_get_str(qstr);
if (!is_blacklisted(arch, mname)) {
- path = g_strdup_printf("qom/%s", mname);
+ char *path = g_strdup_printf("qom/%s", mname);
qtest_add_data_func(path, g_strdup(mname), test_machine);
+ g_free(path);
}
}
diff --git a/tests/test-cutils.c b/tests/test-cutils.c
index 64e3e95ce2..20b0f59ba2 100644
--- a/tests/test-cutils.c
+++ b/tests/test-cutils.c
@@ -378,7 +378,7 @@ static void test_qemu_strtol_hex(void)
static void test_qemu_strtol_max(void)
{
- const char *str = g_strdup_printf("%ld", LONG_MAX);
+ char *str = g_strdup_printf("%ld", LONG_MAX);
char f = 'X';
const char *endptr = &f;
long res = 999;
@@ -389,6 +389,7 @@ static void test_qemu_strtol_max(void)
g_assert_cmpint(err, ==, 0);
g_assert_cmpint(res, ==, LONG_MAX);
g_assert(endptr == str + strlen(str));
+ g_free(str);
}
static void test_qemu_strtol_overflow(void)
@@ -497,7 +498,7 @@ static void test_qemu_strtol_full_trailing(void)
static void test_qemu_strtol_full_max(void)
{
- const char *str = g_strdup_printf("%ld", LONG_MAX);
+ char *str = g_strdup_printf("%ld", LONG_MAX);
long res;
int err;
@@ -505,6 +506,7 @@ static void test_qemu_strtol_full_max(void)
g_assert_cmpint(err, ==, 0);
g_assert_cmpint(res, ==, LONG_MAX);
+ g_free(str);
}
static void test_qemu_strtoul_correct(void)
@@ -662,7 +664,7 @@ static void test_qemu_strtoul_hex(void)
static void test_qemu_strtoul_max(void)
{
- const char *str = g_strdup_printf("%lu", ULONG_MAX);
+ char *str = g_strdup_printf("%lu", ULONG_MAX);
char f = 'X';
const char *endptr = &f;
unsigned long res = 999;
@@ -673,6 +675,7 @@ static void test_qemu_strtoul_max(void)
g_assert_cmpint(err, ==, 0);
g_assert_cmpint(res, ==, ULONG_MAX);
g_assert(endptr == str + strlen(str));
+ g_free(str);
}
static void test_qemu_strtoul_overflow(void)
@@ -776,7 +779,7 @@ static void test_qemu_strtoul_full_trailing(void)
static void test_qemu_strtoul_full_max(void)
{
- const char *str = g_strdup_printf("%lu", ULONG_MAX);
+ char *str = g_strdup_printf("%lu", ULONG_MAX);
unsigned long res = 999;
int err;
@@ -784,6 +787,7 @@ static void test_qemu_strtoul_full_max(void)
g_assert_cmpint(err, ==, 0);
g_assert_cmpint(res, ==, ULONG_MAX);
+ g_free(str);
}
static void test_qemu_strtoll_correct(void)
@@ -941,7 +945,7 @@ static void test_qemu_strtoll_hex(void)
static void test_qemu_strtoll_max(void)
{
- const char *str = g_strdup_printf("%lld", LLONG_MAX);
+ char *str = g_strdup_printf("%lld", LLONG_MAX);
char f = 'X';
const char *endptr = &f;
int64_t res = 999;
@@ -952,6 +956,7 @@ static void test_qemu_strtoll_max(void)
g_assert_cmpint(err, ==, 0);
g_assert_cmpint(res, ==, LLONG_MAX);
g_assert(endptr == str + strlen(str));
+ g_free(str);
}
static void test_qemu_strtoll_overflow(void)
@@ -1058,7 +1063,7 @@ static void test_qemu_strtoll_full_trailing(void)
static void test_qemu_strtoll_full_max(void)
{
- const char *str = g_strdup_printf("%lld", LLONG_MAX);
+ char *str = g_strdup_printf("%lld", LLONG_MAX);
int64_t res;
int err;
@@ -1066,6 +1071,7 @@ static void test_qemu_strtoll_full_max(void)
g_assert_cmpint(err, ==, 0);
g_assert_cmpint(res, ==, LLONG_MAX);
+ g_free(str);
}
static void test_qemu_strtoull_correct(void)
@@ -1223,7 +1229,7 @@ static void test_qemu_strtoull_hex(void)
static void test_qemu_strtoull_max(void)
{
- const char *str = g_strdup_printf("%llu", ULLONG_MAX);
+ char *str = g_strdup_printf("%llu", ULLONG_MAX);
char f = 'X';
const char *endptr = &f;
uint64_t res = 999;
@@ -1234,6 +1240,7 @@ static void test_qemu_strtoull_max(void)
g_assert_cmpint(err, ==, 0);
g_assert_cmpint(res, ==, ULLONG_MAX);
g_assert(endptr == str + strlen(str));
+ g_free(str);
}
static void test_qemu_strtoull_overflow(void)
@@ -1339,7 +1346,7 @@ static void test_qemu_strtoull_full_trailing(void)
static void test_qemu_strtoull_full_max(void)
{
- const char *str = g_strdup_printf("%lld", ULLONG_MAX);
+ char *str = g_strdup_printf("%lld", ULLONG_MAX);
uint64_t res = 999;
int err;
@@ -1347,6 +1354,7 @@ static void test_qemu_strtoull_full_max(void)
g_assert_cmpint(err, ==, 0);
g_assert_cmpint(res, ==, ULLONG_MAX);
+ g_free(str);
}
static void test_qemu_strtosz_simple(void)
diff --git a/tests/test-iov.c b/tests/test-iov.c
index 46ae25efd6..a22d71fd2c 100644
--- a/tests/test-iov.c
+++ b/tests/test-iov.c
@@ -208,6 +208,9 @@ static void test_io(void)
} while(k < j);
}
}
+ iov_free(iov, niov);
+ g_free(buf);
+ g_free(siov);
exit(0);
} else {
@@ -246,6 +249,10 @@ static void test_io(void)
test_iov_bytes(iov, niov, i, j - i);
}
}
+
+ iov_free(iov, niov);
+ g_free(buf);
+ g_free(siov);
}
#endif
}
diff --git a/tests/test-qga.c b/tests/test-qga.c
index dac8fb8c0a..21f44f8915 100644
--- a/tests/test-qga.c
+++ b/tests/test-qga.c
@@ -398,6 +398,7 @@ static void test_qga_file_ops(gconstpointer fix)
/* check content */
path = g_build_filename(fixture->test_dir, "foo", NULL);
f = fopen(path, "r");
+ g_free(path);
g_assert_nonnull(f);
count = fread(tmp, 1, sizeof(tmp), f);
g_assert_cmpint(count, ==, sizeof(helloworld));
@@ -700,7 +701,9 @@ static void test_qga_config(gconstpointer data)
cwd = g_get_current_dir();
cmd = g_strdup_printf("%s%cqemu-ga -D",
cwd, G_DIR_SEPARATOR);
+ g_free(cwd);
g_shell_parse_argv(cmd, NULL, &argv, &error);
+ g_free(cmd);
g_assert_no_error(error);
env[0] = g_strdup_printf("QGA_CONF=tests%cdata%ctest-qga-config",
@@ -708,6 +711,8 @@ static void test_qga_config(gconstpointer data)
env[1] = NULL;
g_spawn_sync(NULL, argv, env, 0,
NULL, NULL, &out, &err, &status, &error);
+ g_strfreev(argv);
+
g_assert_no_error(error);
g_assert_cmpstr(err, ==, "");
g_assert_cmpint(status, ==, 0);
diff --git a/tests/test-string-input-visitor.c b/tests/test-string-input-visitor.c
index d837ebedad..a679fbc678 100644
--- a/tests/test-string-input-visitor.c
+++ b/tests/test-string-input-visitor.c
@@ -228,6 +228,7 @@ static void test_visitor_in_fuzz(TestInputVisitorData *data,
v = visitor_input_test_init(data, buf);
visit_type_intList(v, NULL, &ilres, NULL);
+ qapi_free_intList(ilres);
visitor_input_teardown(data, NULL);
v = visitor_input_test_init(data, buf);
diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index 41fd841aed..d8da26f974 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -50,16 +50,20 @@ static QEMUFile *open_test_file(bool write)
{
int fd = dup(temp_fd);
QIOChannel *ioc;
+ QEMUFile *f;
+
lseek(fd, 0, SEEK_SET);
if (write) {
g_assert_cmpint(ftruncate(fd, 0), ==, 0);
}
ioc = QIO_CHANNEL(qio_channel_file_new_fd(fd));
if (write) {
- return qemu_fopen_channel_output(ioc);
+ f = qemu_fopen_channel_output(ioc);
} else {
- return qemu_fopen_channel_input(ioc);
+ f = qemu_fopen_channel_input(ioc);
}
+ object_unref(OBJECT(ioc));
+ return f;
}
#define SUCCESS(val) \