Skip to contentSkip to conversation

hw/sd/sdhci: free irq on exit

PATCH Applied Zheng Huang 2 participants 3 messages Mar 28, 2025 – Mar 31, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/sd/sdhci: free irq on exit

Hi,

This patch fixes a memory leak bug in sdhci_pci_realize(). s->irq is not freed in sdhci_pci_exit().

---
 hw/sd/sdhci-pci.c | 2 ++
 1 file changed, 2 insertions(+)
hw/sd/sdhci-pci.c +2 -0
index 5268c0dee5..f5296d58ca 100644
@@ -18,6 +18,7 @@
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "qemu/module.h"
+#include "hw/irq.h"
 #include "hw/qdev-properties.h"
 #include "hw/sd/sdhci.h"
 #include "sdhci-internal.h"
@@ -50,6 +51,7 @@ static void sdhci_pci_exit(PCIDevice *dev)
 
     sdhci_common_unrealize(s);
     sdhci_uninitfn(s);
+    qemu_free_irq(s->irq);
 }
 
 static void sdhci_pci_class_init(ObjectClass *klass, void *data)
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 24 lines · Zheng Huang

Hi,

This patch fixes a memory leak bug in sdhci_pci_realize(). s->irq is not freed in sdhci_pci_exit().

---
  hw/sd/sdhci-pci.c | 2 ++
  1 file changed, 2 insertions(+)
hw/sd/sdhci-pci.c +1 -0
index 5268c0dee5..f5296d58ca 100644
@@ -18,6 +18,7 @@
  #include "qemu/osdep.h"
  #include "qapi/error.h"
  #include "qemu/module.h"
+#include "hw/irq.h"
  #include "hw/qdev-properties.h"
  #include "hw/sd/sdhci.h"
  #include "sdhci-internal.h"

hw/sd/sdhci-pci.c static void sdhci_pci_exit(PCIDevice *dev) · line 51

Quoted 1 line
hw/sd/sdhci-pci.c +0 -0
@@ -50,6 +51,7 @@ static void sdhci_pci_exit(PCIDevice *dev)
 

Better move the call here, do release in opposite order of alloc.

hw/sd/sdhci-pci.c static void sdhci_pci_exit(PCIDevice *dev) · line 55

Quoted 4 lines
hw/sd/sdhci-pci.c +1 -0
      sdhci_common_unrealize(s);
      sdhci_uninitfn(s);
+    qemu_free_irq(s->irq);
  }

Regardless: