qemu-ppc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 6/6] hw/isa/piix4: Fix leak removing unuseful qemu_allocate_irqs(


From: Philippe Mathieu-Daudé
Subject: [PATCH 6/6] hw/isa/piix4: Fix leak removing unuseful qemu_allocate_irqs() call
Date: Wed, 24 Mar 2021 00:13:58 +0100

We locally create an input IRQ with qemu_allocate_irqs() to
pass it as output IRQ of the PIC, but its handler simply dispatch
into another of our output IRQ ("intr" output).

Simplify by directly connecting the PIC output to our "intr"
output.

This fixes when using QEMU built with --enable-sanitizers:

  ==338425==ERROR: LeakSanitizer: detected memory leaks

  Direct leak of 8 byte(s) in 1 object(s) allocated from:
    #0 0x5641b361e1df in malloc (qemu-system-mips+0x1b201df)
    #1 0x7f995e683958 in g_malloc (/lib64/libglib-2.0.so.0+0x58958)
    #2 0x5641b5558e36 in qemu_allocate_irqs hw/core/irq.c:66:12
    #3 0x5641b4161817 in piix4_realize hw/isa/piix4.c:171:21
    #4 0x5641b42f077a in pci_qdev_realize hw/pci/pci.c:2114:9
    #5 0x5641b554c802 in device_set_realized hw/core/qdev.c:761:13
    #6 0x5641b5578458 in property_set_bool qom/object.c:2257:5
    #7 0x5641b55709e2 in object_property_set qom/object.c:1402:5
    #8 0x5641b55861c9 in object_property_set_qobject qom/qom-qobject.c:28:10
    #9 0x5641b5571831 in object_property_set_bool qom/object.c:1472:15
   #10 0x5641b55410fd in qdev_realize hw/core/qdev.c:389:12

Fixes: 078778c5a55 ("piix4: Add an i8259 Interrupt Controller as specified in 
datasheet")
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/isa/piix4.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c
index a50d97834c7..79ed20e2a1a 100644
--- a/hw/isa/piix4.c
+++ b/hw/isa/piix4.c
@@ -103,12 +103,6 @@ static const VMStateDescription vmstate_piix4 = {
     }
 };
 
-static void piix4_request_i8259_irq(void *opaque, int irq, int level)
-{
-    PIIX4State *s = opaque;
-    qemu_set_irq(s->cpu_intr, level);
-}
-
 static void piix4_set_i8259_irq(void *opaque, int irq, int level)
 {
     PIIX4State *s = opaque;
@@ -149,7 +143,6 @@ static void piix4_realize(PCIDevice *dev, Error **errp)
 {
     PIIX4State *s = PIIX4_PCI_DEVICE(dev);
     ISABus *isa_bus;
-    qemu_irq *i8259_out_irq;
 
     isa_bus = isa_bus_new(DEVICE(dev), pci_address_space(dev),
                           pci_address_space_io(dev), errp);
@@ -168,8 +161,7 @@ static void piix4_realize(PCIDevice *dev, Error **errp)
                                         PIIX_RCR_IOPORT, &s->rcr_mem, 1);
 
     /* initialize i8259 pic */
-    i8259_out_irq = qemu_allocate_irqs(piix4_request_i8259_irq, s, 1);
-    s->isa = i8259_init(isa_bus, *i8259_out_irq);
+    s->isa = i8259_init(isa_bus, s->cpu_intr);
 
     /* initialize ISA irqs */
     isa_bus_irqs(isa_bus, s->isa);
-- 
2.26.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]