From 78e85fa40c2bbae7f0b6da4e4f987bb8afd465bf Mon Sep 17 00:00:00 2001 From: Chen Qun Date: Mon, 27 Jul 2020 20:39:07 +0800 Subject: [PATCH] bugfix: irq: Avoid covering object refcount of qemu_irq Avoid covering object refcount of qemu_irq, otherwise it may causes memory leak. Signed-off-by: Keqian Zhu --- ...-covering-object-refcount-of-qemu_ir.patch | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 bugfix-irq-Avoid-covering-object-refcount-of-qemu_ir.patch diff --git a/bugfix-irq-Avoid-covering-object-refcount-of-qemu_ir.patch b/bugfix-irq-Avoid-covering-object-refcount-of-qemu_ir.patch new file mode 100644 index 0000000..5a329c7 --- /dev/null +++ b/bugfix-irq-Avoid-covering-object-refcount-of-qemu_ir.patch @@ -0,0 +1,32 @@ +From 32353a7838f9ff38c5bd768252a79bd8e485658b Mon Sep 17 00:00:00 2001 +From: Keqian Zhu +Date: Mon, 27 Jul 2020 20:39:07 +0800 +Subject: [PATCH] bugfix: irq: Avoid covering object refcount of qemu_irq + +Avoid covering object refcount of qemu_irq, otherwise it may causes +memory leak. + +Signed-off-by: Keqian Zhu +--- + hw/core/irq.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/hw/core/irq.c b/hw/core/irq.c +index 8a9cbdd556..700a6373d8 100644 +--- a/hw/core/irq.c ++++ b/hw/core/irq.c +@@ -126,7 +126,10 @@ 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; ++ old_irqs[i]->n = gpio_in[i]->n; ++ + gpio_in[i]->handler = handler; + gpio_in[i]->opaque = &old_irqs[i]; + } +-- +2.27.0 +