[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 2/5] hw/ide/sii3112: Use qdev gpio rather than qemu_allocate_irqs(
From: |
John Snow |
Subject: |
[PULL 2/5] hw/ide/sii3112: Use qdev gpio rather than qemu_allocate_irqs() |
Date: |
Fri, 27 Mar 2020 16:14:58 -0400 |
From: Peter Maydell <address@hidden>
Coverity points out (CID 1421984) that we are leaking the
memory returned by qemu_allocate_irqs(). We can avoid this
leak by switching to using qdev_init_gpio_in(); the base
class finalize will free the irqs that this allocates under
the hood.
Signed-off-by: Peter Maydell <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Reviewed-by: John Snow <address@hidden>
Tested-by: BALATON Zoltan <address@hidden>
Message-id: address@hidden
[Maintainer edit: replace `DEVICE(dev)` by `ds` --js]
Signed-off-by: John Snow <address@hidden>
---
hw/ide/sii3112.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/hw/ide/sii3112.c b/hw/ide/sii3112.c
index 06605d7af2..d69079c3d9 100644
--- a/hw/ide/sii3112.c
+++ b/hw/ide/sii3112.c
@@ -251,8 +251,8 @@ static void sii3112_pci_realize(PCIDevice *dev, Error
**errp)
{
SiI3112PCIState *d = SII3112_PCI(dev);
PCIIDEState *s = PCI_IDE(dev);
+ DeviceState *ds = DEVICE(dev);
MemoryRegion *mr;
- qemu_irq *irq;
int i;
pci_config_set_interrupt_pin(dev->config, 1);
@@ -280,10 +280,10 @@ static void sii3112_pci_realize(PCIDevice *dev, Error
**errp)
memory_region_init_alias(mr, OBJECT(d), "sii3112.bar4", &d->mmio, 0, 16);
pci_register_bar(dev, 4, PCI_BASE_ADDRESS_SPACE_IO, mr);
- irq = qemu_allocate_irqs(sii3112_set_irq, d, 2);
+ qdev_init_gpio_in(ds, sii3112_set_irq, 2);
for (i = 0; i < 2; i++) {
- ide_bus_new(&s->bus[i], sizeof(s->bus[i]), DEVICE(dev), i, 1);
- ide_init2(&s->bus[i], irq[i]);
+ ide_bus_new(&s->bus[i], sizeof(s->bus[i]), ds, i, 1);
+ ide_init2(&s->bus[i], qdev_get_gpio_in(ds, i));
bmdma_init(&s->bus[i], &s->bmdma[i], s);
s->bmdma[i].bus = &s->bus[i];
--
2.21.1
- [PULL 0/5] Ide patches, John Snow, 2020/03/27
- [PULL 1/5] fdc/i8257: implement verify transfer mode, John Snow, 2020/03/27
- [PULL 2/5] hw/ide/sii3112: Use qdev gpio rather than qemu_allocate_irqs(),
John Snow <=
- [PULL 3/5] via-ide: don't use PCI level for legacy IRQs, John Snow, 2020/03/27
- [PULL 4/5] via-ide: use qdev gpio rather than qemu_allocate_irqs(), John Snow, 2020/03/27
- [PULL 5/5] cmd646-ide: use qdev gpio rather than qemu_allocate_irqs(), John Snow, 2020/03/27
- Re: [PULL 0/5] Ide patches, Peter Maydell, 2020/03/28