qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH for-5.0 0/3] ide: fix potential memory leaks (plus one via-ide bugfix)
@ 2020-03-24 21:05 Mark Cave-Ayland
  2020-03-24 21:05 ` [PATCH for-5.0 1/3] via-ide: don't use PCI level for legacy IRQs Mark Cave-Ayland
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Mark Cave-Ayland @ 2020-03-24 21:05 UTC (permalink / raw)
  To: peter.maydell, jsnow, balaton, qemu-devel, qemu-ppc, qemu-block

This was supposed to be a simple patchset to switch via-ide and cmd646-ide
over to use qdev gpio in the same way as Peter's patch did for sil3112, but
at the same time I spotted a silly mistake in my last set of via-ide
patches which is included as patch 1.

I'm not sure exactly why Coverity CID 1421984 isn't triggered by the
via-ide and cmd646-ide devices, however given the simplicity of the fix it
seems worth doing just to keep everything the same and ensure it won't
suddenly appear in future.

The via-ide changes were tested using the instructions provided by Zoltan
for MIPS fulong2e and PPC pegasos2, whilst the cmd646 change was tested
using one of my SPARC64 Linux test images.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>


Mark Cave-Ayland (3):
  via-ide: don't use PCI level for legacy IRQs
  via-ide: use qdev gpio rather than qemu_allocate_irqs()
  cmd646-ide: use qdev gpio rather than qemu_allocate_irqs()

 hw/ide/cmd646.c | 9 ++++-----
 hw/ide/via.c    | 7 ++++---
 2 files changed, 8 insertions(+), 8 deletions(-)

-- 
2.20.1



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

* [PATCH for-5.0 1/3] via-ide: don't use PCI level for legacy IRQs
  2020-03-24 21:05 [PATCH for-5.0 0/3] ide: fix potential memory leaks (plus one via-ide bugfix) Mark Cave-Ayland
@ 2020-03-24 21:05 ` Mark Cave-Ayland
  2020-03-24 21:05 ` [PATCH for-5.0 2/3] via-ide: use qdev gpio rather than qemu_allocate_irqs() Mark Cave-Ayland
  2020-03-24 21:05 ` [PATCH for-5.0 3/3] cmd646-ide: " Mark Cave-Ayland
  2 siblings, 0 replies; 4+ messages in thread
From: Mark Cave-Ayland @ 2020-03-24 21:05 UTC (permalink / raw)
  To: peter.maydell, jsnow, balaton, qemu-devel, qemu-ppc, qemu-block

The PCI level calculation was accidentally left in when rebasing from a
previous patchset. Since both IRQs are driven separately, the value
being passed into the IRQ handler should be used directly.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/ide/via.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/hw/ide/via.c b/hw/ide/via.c
index 8de4945cc1..2a55b7fbc6 100644
--- a/hw/ide/via.c
+++ b/hw/ide/via.c
@@ -112,7 +112,6 @@ static void via_ide_set_irq(void *opaque, int n, int level)
         d->config[0x70 + n * 8] &= ~0x80;
     }
 
-    level = (d->config[0x70] & 0x80) || (d->config[0x78] & 0x80);
     qemu_set_irq(isa_get_irq(NULL, 14 + n), level);
 }
 
-- 
2.20.1



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

* [PATCH for-5.0 2/3] via-ide: use qdev gpio rather than qemu_allocate_irqs()
  2020-03-24 21:05 [PATCH for-5.0 0/3] ide: fix potential memory leaks (plus one via-ide bugfix) Mark Cave-Ayland
  2020-03-24 21:05 ` [PATCH for-5.0 1/3] via-ide: don't use PCI level for legacy IRQs Mark Cave-Ayland
@ 2020-03-24 21:05 ` Mark Cave-Ayland
  2020-03-24 21:05 ` [PATCH for-5.0 3/3] cmd646-ide: " Mark Cave-Ayland
  2 siblings, 0 replies; 4+ messages in thread
From: Mark Cave-Ayland @ 2020-03-24 21:05 UTC (permalink / raw)
  To: peter.maydell, jsnow, balaton, qemu-devel, qemu-ppc, qemu-block

This prevents the memory from qemu_allocate_irqs() from being leaked which
can in some cases be spotted by Coverity (CID 1421984).

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/ide/via.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/hw/ide/via.c b/hw/ide/via.c
index 2a55b7fbc6..be09912b33 100644
--- a/hw/ide/via.c
+++ b/hw/ide/via.c
@@ -160,6 +160,7 @@ static void via_ide_reset(DeviceState *dev)
 static void via_ide_realize(PCIDevice *dev, Error **errp)
 {
     PCIIDEState *d = PCI_IDE(dev);
+    DeviceState *ds = DEVICE(dev);
     uint8_t *pci_conf = dev->config;
     int i;
 
@@ -187,9 +188,10 @@ static void via_ide_realize(PCIDevice *dev, Error **errp)
     bmdma_setup_bar(d);
     pci_register_bar(dev, 4, PCI_BASE_ADDRESS_SPACE_IO, &d->bmdma_bar);
 
+    qdev_init_gpio_in(ds, via_ide_set_irq, 2);
     for (i = 0; i < 2; i++) {
-        ide_bus_new(&d->bus[i], sizeof(d->bus[i]), DEVICE(d), i, 2);
-        ide_init2(&d->bus[i], qemu_allocate_irq(via_ide_set_irq, d, i));
+        ide_bus_new(&d->bus[i], sizeof(d->bus[i]), ds, i, 2);
+        ide_init2(&d->bus[i], qdev_get_gpio_in(ds, i));
 
         bmdma_init(&d->bus[i], &d->bmdma[i], d);
         d->bmdma[i].bus = &d->bus[i];
-- 
2.20.1



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

* [PATCH for-5.0 3/3] cmd646-ide: use qdev gpio rather than qemu_allocate_irqs()
  2020-03-24 21:05 [PATCH for-5.0 0/3] ide: fix potential memory leaks (plus one via-ide bugfix) Mark Cave-Ayland
  2020-03-24 21:05 ` [PATCH for-5.0 1/3] via-ide: don't use PCI level for legacy IRQs Mark Cave-Ayland
  2020-03-24 21:05 ` [PATCH for-5.0 2/3] via-ide: use qdev gpio rather than qemu_allocate_irqs() Mark Cave-Ayland
@ 2020-03-24 21:05 ` Mark Cave-Ayland
  2 siblings, 0 replies; 4+ messages in thread
From: Mark Cave-Ayland @ 2020-03-24 21:05 UTC (permalink / raw)
  To: peter.maydell, jsnow, balaton, qemu-devel, qemu-ppc, qemu-block

This prevents the memory from qemu_allocate_irqs() from being leaked which
can in some cases be spotted by Coverity (CID 1421984).

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/ide/cmd646.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/hw/ide/cmd646.c b/hw/ide/cmd646.c
index 699f25824d..c254631485 100644
--- a/hw/ide/cmd646.c
+++ b/hw/ide/cmd646.c
@@ -249,8 +249,8 @@ static void cmd646_pci_config_write(PCIDevice *d, uint32_t addr, uint32_t val,
 static void pci_cmd646_ide_realize(PCIDevice *dev, Error **errp)
 {
     PCIIDEState *d = PCI_IDE(dev);
+    DeviceState *ds = DEVICE(dev);
     uint8_t *pci_conf = dev->config;
-    qemu_irq *irq;
     int i;
 
     pci_conf[PCI_CLASS_PROG] = 0x8f;
@@ -291,16 +291,15 @@ static void pci_cmd646_ide_realize(PCIDevice *dev, Error **errp)
     /* TODO: RST# value should be 0 */
     pci_conf[PCI_INTERRUPT_PIN] = 0x01; // interrupt on pin 1
 
-    irq = qemu_allocate_irqs(cmd646_set_irq, d, 2);
+    qdev_init_gpio_in(ds, cmd646_set_irq, 2);
     for (i = 0; i < 2; i++) {
-        ide_bus_new(&d->bus[i], sizeof(d->bus[i]), DEVICE(dev), i, 2);
-        ide_init2(&d->bus[i], irq[i]);
+        ide_bus_new(&d->bus[i], sizeof(d->bus[i]), ds, i, 2);
+        ide_init2(&d->bus[i], qdev_get_gpio_in(ds, i));
 
         bmdma_init(&d->bus[i], &d->bmdma[i], d);
         d->bmdma[i].bus = &d->bus[i];
         ide_register_restart_cb(&d->bus[i]);
     }
-    g_free(irq);
 }
 
 static void pci_cmd646_ide_exitfn(PCIDevice *dev)
-- 
2.20.1



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

end of thread, other threads:[~2020-03-24 21:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-24 21:05 [PATCH for-5.0 0/3] ide: fix potential memory leaks (plus one via-ide bugfix) Mark Cave-Ayland
2020-03-24 21:05 ` [PATCH for-5.0 1/3] via-ide: don't use PCI level for legacy IRQs Mark Cave-Ayland
2020-03-24 21:05 ` [PATCH for-5.0 2/3] via-ide: use qdev gpio rather than qemu_allocate_irqs() Mark Cave-Ayland
2020-03-24 21:05 ` [PATCH for-5.0 3/3] cmd646-ide: " Mark Cave-Ayland

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