qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bugfix: irq: Avoid covering object refcount of qemu_irq
@ 2020-07-27 13:02 Keqian Zhu
  2020-07-27 14:37 ` Li Qiang
  2020-07-27 14:41 ` Peter Maydell
  0 siblings, 2 replies; 8+ messages in thread
From: Keqian Zhu @ 2020-07-27 13:02 UTC (permalink / raw)
  To: qemu-devel, qemu-arm
  Cc: Thomas Huth, yezengruan, Keqian Zhu, Li Qiang,
	Dr . David Alan Gilbert, Esteban Bosse, Paolo Bonzini,
	wanghaibin.wang, Philippe Mathieu-Daudé

Avoid covering object refcount of qemu_irq, otherwise it may causes
memory leak.

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



^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-07-28  9:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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).