[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 13/13] hw/m68k/mcf5206: Don't leak IRQs in mcf5206_mbar_realize()
From: |
Thomas Huth |
Subject: |
[PULL 13/13] hw/m68k/mcf5206: Don't leak IRQs in mcf5206_mbar_realize() |
Date: |
Wed, 9 Dec 2020 10:48:56 +0100 |
From: Peter Maydell <peter.maydell@linaro.org>
Coverity points out that the realize function for the TYPE_MCF5206_MBAR
device leaks the IRQ array it allocates with qemu_allocate_irqs().
Keep a pointer to it in the device state struct to avoid the leak.
(Since it needs to stay around for the life of the simulation there
is no need to actually free it, and the leak was harmless.)
Fixes: Coverity CID 1432412
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Thomas Huth <huth@tuxfamily.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20201120172314.14725-1-peter.maydell@linaro.org>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
hw/m68k/mcf5206.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/hw/m68k/mcf5206.c b/hw/m68k/mcf5206.c
index 51d2e0da1c..92a194dbc4 100644
--- a/hw/m68k/mcf5206.c
+++ b/hw/m68k/mcf5206.c
@@ -164,6 +164,7 @@ typedef struct {
M68kCPU *cpu;
MemoryRegion iomem;
+ qemu_irq *pic;
m5206_timer_state *timer[2];
void *uart[2];
uint8_t scr;
@@ -588,17 +589,16 @@ static const MemoryRegionOps m5206_mbar_ops = {
static void mcf5206_mbar_realize(DeviceState *dev, Error **errp)
{
m5206_mbar_state *s = MCF5206_MBAR(dev);
- qemu_irq *pic;
memory_region_init_io(&s->iomem, NULL, &m5206_mbar_ops, s,
"mbar", 0x00001000);
sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem);
- pic = qemu_allocate_irqs(m5206_mbar_set_irq, s, 14);
- s->timer[0] = m5206_timer_init(pic[9]);
- s->timer[1] = m5206_timer_init(pic[10]);
- s->uart[0] = mcf_uart_init(pic[12], serial_hd(0));
- s->uart[1] = mcf_uart_init(pic[13], serial_hd(1));
+ s->pic = qemu_allocate_irqs(m5206_mbar_set_irq, s, 14);
+ s->timer[0] = m5206_timer_init(s->pic[9]);
+ s->timer[1] = m5206_timer_init(s->pic[10]);
+ s->uart[0] = mcf_uart_init(s->pic[12], serial_hd(0));
+ s->uart[1] = mcf_uart_init(s->pic[13], serial_hd(1));
s->cpu = M68K_CPU(qemu_get_cpu(0));
}
--
2.18.4
- [PULL 01/13] gitlab-ci: Document 'build-tcg-disabled' is a KVM X86 job, (continued)
- [PULL 01/13] gitlab-ci: Document 'build-tcg-disabled' is a KVM X86 job, Thomas Huth, 2020/12/09
- [PULL 02/13] gitlab-ci: Replace YAML anchors by extends (cross_system_build_job), Thomas Huth, 2020/12/09
- [PULL 03/13] gitlab-ci: Introduce 'cross_accel_build_job' template, Thomas Huth, 2020/12/09
- [PULL 04/13] gitlab-ci: Add KVM s390x cross-build jobs, Thomas Huth, 2020/12/09
- [PULL 05/13] gitlab-ci: Add Xen cross-build jobs, Thomas Huth, 2020/12/09
- [PULL 06/13] test-qga: fix a resource leak in test_qga_guest_get_osinfo(), Thomas Huth, 2020/12/09
- [PULL 07/13] tests/qtest/fuzz-test: Quit test_lp1878642 once done, Thomas Huth, 2020/12/09
- [PULL 11/13] gitlab-ci: Move user-static test across to gitlab, Thomas Huth, 2020/12/09
- [PULL 12/13] gitlab-ci: Move coroutine tests across to gitlab, Thomas Huth, 2020/12/09
- [PULL 10/13] gitlab-ci: Update 'build-disabled' to cover all configurable options, Thomas Huth, 2020/12/09
- [PULL 13/13] hw/m68k/mcf5206: Don't leak IRQs in mcf5206_mbar_realize(),
Thomas Huth <=
- [PULL 09/13] gitlab-ci: Split CONFIGURE_ARGS one argument per line for build-disabled, Thomas Huth, 2020/12/09
- [PULL 08/13] fuzz: avoid double-fetches by default, Thomas Huth, 2020/12/09
- Re: [PULL 00/13] Gitlab-CI and test patches, Peter Maydell, 2020/12/09