[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2 20/30] tests: fix e1000e leaks
From: |
Markus Armbruster |
Subject: |
Re: [Qemu-devel] [PATCH v2 20/30] tests: fix e1000e leaks |
Date: |
Mon, 27 Feb 2017 15:12:21 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) |
Marc-André Lureau <address@hidden> writes:
> Spotted by ASAN.
>
> Signed-off-by: Marc-André Lureau <address@hidden>
> ---
> tests/e1000e-test.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/tests/e1000e-test.c b/tests/e1000e-test.c
> index 8c42ca919f..c612dc64ec 100644
> --- a/tests/e1000e-test.c
> +++ b/tests/e1000e-test.c
> @@ -99,7 +99,10 @@ static QPCIBus *test_bus;
>
> static void e1000e_pci_foreach_callback(QPCIDevice *dev, int devfn, void
> *data)
> {
> - *(QPCIDevice **) data = dev;
> + QPCIDevice **res = data;
> +
> + g_assert_null(*res);
> + *res = dev;
> }
>
> static QPCIDevice *e1000e_device_find(QPCIBus *bus)
{
static const int e1000e_vendor_id = 0x8086;
static const int e1000e_dev_id = 0x10D3;
QPCIDevice *e1000e_dev = NULL;
qpci_device_foreach(bus, e1000e_vendor_id, e1000e_dev_id,
e1000e_pci_foreach_callback, &e1000e_dev);
This hunk adds an assertion. I guess it checks that we're finding no
more than one e1000e device. The connection to the stated purpose of
this patch isn't obvious, but I think I got it: each hit allocates, but
you have only one g_free(), below. Okay, but explaining this briefly
the commit message wouldn't hurt.
> @@ -403,6 +406,7 @@ static void data_test_clear(e1000e_device *d)
> e1000e_device_clear(test_bus, d);
> close(test_sockets[0]);
> pc_alloc_uninit(test_alloc);
> + g_free(d->pci_dev);
> qpci_free_pc(test_bus);
> qtest_end();
> }
Reviewed-by: Markus Armbruster <address@hidden>
- Re: [Qemu-devel] [PATCH v2 13/30] tests: fix ipmi-kcs-test leak, (continued)
- [Qemu-devel] [PATCH v2 15/30] pc: pcihp: avoid adding ACPI_PCIHP_PROP_BSEL twice, Marc-André Lureau, 2017/02/21
- [Qemu-devel] [PATCH v2 16/30] tests: fix eepro100-test leak, Marc-André Lureau, 2017/02/21
- [Qemu-devel] [PATCH v2 17/30] tests: fix tco-test leaks, Marc-André Lureau, 2017/02/21
- [Qemu-devel] [PATCH v2 18/30] tests: fix e1000-test leak, Marc-André Lureau, 2017/02/21
- [Qemu-devel] [PATCH v2 19/30] tests: fix i440fx-test leaks, Marc-André Lureau, 2017/02/21
- [Qemu-devel] [PATCH v2 20/30] tests: fix e1000e leaks, Marc-André Lureau, 2017/02/21
- Re: [Qemu-devel] [PATCH v2 20/30] tests: fix e1000e leaks,
Markus Armbruster <=
- [Qemu-devel] [PATCH v2 21/30] tests: fix virtio-scsi-test leak, Marc-André Lureau, 2017/02/21
- [Qemu-devel] [PATCH v2 22/30] tests: fix virtio-9p-test leaks, Marc-André Lureau, 2017/02/21
- [Qemu-devel] [PATCH v2 23/30] bus: do not unref hotplug handler, Marc-André Lureau, 2017/02/21
- [Qemu-devel] [PATCH v2 24/30] usb: replace handle_destroy with unrealize, Marc-André Lureau, 2017/02/21
- [Qemu-devel] [PATCH v2 26/30] tests: allows to run single test in usb-hcd-ehci-test, Marc-André Lureau, 2017/02/21