From: Paolo Bonzini <pbonzini@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [PATCH 1/8] ide: fix leak from qemu_allocate_irqs
Date: Tue, 1 Oct 2019 18:52:14 +0200 [thread overview]
Message-ID: <0afcb999-e8ba-8212-47f4-8980f35502a3@redhat.com> (raw)
In-Reply-To: <CAFEAcA-o6DS4JUHGnm4M=nD78U4esN5Jj7F5cuJaA8U1YBrTbQ@mail.gmail.com>
On 01/10/19 17:58, Peter Maydell wrote:
> On Tue, 1 Oct 2019 at 14:38, Paolo Bonzini <pbonzini@redhat.com> wrote:
>>
>> The array returned by qemu_allocate_irqs is malloced, free it.
>>
>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>> ---
>> hw/ide/cmd646.c | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/hw/ide/cmd646.c b/hw/ide/cmd646.c
>> index f3ccd11..19984d2 100644
>> --- a/hw/ide/cmd646.c
>> +++ b/hw/ide/cmd646.c
>> @@ -300,6 +300,7 @@ static void pci_cmd646_ide_realize(PCIDevice *dev, Error **errp)
>> d->bmdma[i].bus = &d->bus[i];
>> ide_register_restart_cb(&d->bus[i]);
>> }
>> + g_free(irq);
>>
>> vmstate_register(DEVICE(dev), 0, &vmstate_ide_pci, d);
>> qemu_register_reset(cmd646_reset, d);
>> --
>> 1.8.3.1
>
> It's a bit weird to be calling qemu_allocate_irqs() here in the
> first place -- usually you'd just have a qemu_irq irqs[2] array
> in the device state struct, qemu_allocate_irq(irq[i], ...) and
> pass irq[i] to the ide_init2() function to tell it what
> qemu_irq to use. Or else you'd keep the pointer to the
> allocated irqs array in the device state struct, so as
> to be able to free it on any theoretical hot-unplug your
> device might support. Calling qemu_allocate_irqs() and then
> immediately freeing the array means that there are now
> two actual qemu_irqs floating around which are supposed
> to be owned by this device but which it has no way to
> get hold of any more. This is only not a leak because
> the cmd646 doesn't support hot-unplug.
>
> (Hot take version : we should be getting rid of qemu_allocate_irqs()
> entirely: it is essentially a "pre-QOM" API and there are better
> ways to phrase code that's currently calling it.)
Yes, I agree, and it's why I didn't mind doing the quick fix that gets
rid of the boot-serial-test leak the easy way.
Paolo
next prev parent reply other threads:[~2019-10-01 17:04 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-01 13:36 [PATCH ci-fix 0/8] fix various memory leaks (but not all) Paolo Bonzini
2019-10-01 13:36 ` [PATCH 1/8] ide: fix leak from qemu_allocate_irqs Paolo Bonzini
2019-10-01 14:25 ` Thomas Huth
2019-10-01 15:28 ` Eric Blake
2019-10-01 15:58 ` Peter Maydell
2019-10-01 16:52 ` Paolo Bonzini [this message]
2019-10-01 13:36 ` [PATCH 2/8] microblaze: fix leak of fdevice tree blob Paolo Bonzini
2019-10-01 14:01 ` Philippe Mathieu-Daudé
2019-10-01 13:36 ` [PATCH 3/8] mcf5208: fix leak from qemu_allocate_irqs Paolo Bonzini
2019-10-01 14:28 ` Thomas Huth
2019-10-01 13:36 ` [PATCH 4/8] hppa: fix leak from g_strdup_printf Paolo Bonzini
2019-10-01 13:59 ` Philippe Mathieu-Daudé
2019-10-01 13:36 ` [PATCH 5/8] mips: fix memory leaks in board initialization Paolo Bonzini
2019-10-01 14:34 ` Thomas Huth
2019-10-01 13:36 ` [PATCH 6/8] cris: do not leak struct cris_disasm_data Paolo Bonzini
2019-10-01 13:36 ` [PATCH 7/8] lm32: do not leak memory on object_new/object_unref Paolo Bonzini
2019-10-01 14:04 ` Philippe Mathieu-Daudé
2019-10-01 13:36 ` [PATCH 8/8] docker: test-debug: disable LeakSanitizer Paolo Bonzini
2019-10-01 13:59 ` Philippe Mathieu-Daudé
2019-10-01 16:53 ` Paolo Bonzini
2019-10-01 19:28 ` [PATCH ci-fix 0/8] fix various memory leaks (but not all) no-reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0afcb999-e8ba-8212-47f4-8980f35502a3@redhat.com \
--to=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).