qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: zhukeqian <zhukeqian1@huawei.com>
To: Li Qiang <liq3ea@gmail.com>
Cc: "Thomas Huth" <thuth@redhat.com>,
	"Esteban Bosse" <estebanbosse@gmail.com>,
	"Qemu Developers" <qemu-devel@nongnu.org>,
	"Dr . David Alan Gilbert" <dgilbert@redhat.com>,
	yezengruan@huawei.com, qemu-arm@nongnu.org,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	wanghaibin.wang@huawei.com,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>
Subject: Re: [PATCH] bugfix: irq: Avoid covering object refcount of qemu_irq
Date: Tue, 28 Jul 2020 09:29:50 +0800	[thread overview]
Message-ID: <b96f7fc1-17dc-6913-16fb-30c7c5ea3beb@huawei.com> (raw)
In-Reply-To: <CAKXe6S+L=Uze9Eo8jmPgpCDob_S_fXzvquHw2D974_5+haKdsw@mail.gmail.com>

Hi Qiang,

On 2020/7/27 22:37, Li Qiang wrote:
> Keqian Zhu <zhukeqian1@huawei.com> 于2020年7月27日周一 下午9:03写道:
>>
>> Avoid covering object refcount of qemu_irq, otherwise it may causes
>> memory leak.
> 
> Any reproducer?
> 
In mainline Qemu. this function is only used in qtest. One of our internal
self-developed module also use this function. The memory leak is reported
by ASAN.

Thanks,
Keqian

> Thanks,
> Li Qiang
> 
>>
>> Signed-off-by: Keqian Zhu <zhukeqian1@huawei.com>
>> ---
>>  hw/core/irq.c | 4 +++-
>>  1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/hw/core/irq.c b/hw/core/irq.c
>> index fb3045b912..59af4dfc74 100644
>> --- a/hw/core/irq.c
>> +++ b/hw/core/irq.c
>> @@ -125,7 +125,9 @@ void qemu_irq_intercept_in(qemu_irq *gpio_in, qemu_irq_handler handler, int n)
>>      int i;
>>      qemu_irq *old_irqs = qemu_allocate_irqs(NULL, NULL, n);
>>      for (i = 0; i < n; i++) {
>> -        *old_irqs[i] = *gpio_in[i];
>> +        old_irqs[i]->handler = gpio_in[i]->handler;
>> +        old_irqs[i]->opaque = gpio_in[i]->opaque;
>> +
>>          gpio_in[i]->handler = handler;
>>          gpio_in[i]->opaque = &old_irqs[i];
>>      }
>> --
>> 2.19.1
>>
> .
> 


  reply	other threads:[~2020-07-28  1:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-27 13:02 [PATCH] bugfix: irq: Avoid covering object refcount of qemu_irq Keqian Zhu
2020-07-27 14:37 ` Li Qiang
2020-07-28  1:29   ` zhukeqian [this message]
2020-07-27 14:41 ` Peter Maydell
2020-07-28  1:36   ` zhukeqian
2020-07-28  8:48   ` Thomas Huth
2020-07-28  9:05     ` zhukeqian
2020-07-28  9:48     ` Peter Maydell

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=b96f7fc1-17dc-6913-16fb-30c7c5ea3beb@huawei.com \
    --to=zhukeqian1@huawei.com \
    --cc=dgilbert@redhat.com \
    --cc=estebanbosse@gmail.com \
    --cc=liq3ea@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@redhat.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.com \
    --cc=wanghaibin.wang@huawei.com \
    --cc=yezengruan@huawei.com \
    /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).