diff mbox series

hw/sd/sdhci: free irq on exit

Message ID 09ddf42b-a6db-42d5-954b-148d09d8d6cc@gmail.com (mailing list archive)
State New
Headers show
Series hw/sd/sdhci: free irq on exit | expand

Commit Message

Zheng Huang March 28, 2025, 9:49 a.m. UTC
Hi,

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

Signed-off-by: Zheng Huang <hz1624917200@gmail.com>

---
 hw/sd/sdhci-pci.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Philippe Mathieu-Daudé March 28, 2025, 6:08 p.m. UTC | #1
On 28/3/25 10:49, Zheng Huang wrote:
> Hi,
> 
> This patch fixes a memory leak bug in `sdhci_pci_realize()`. `s->irq` is
> not freed in `sdhci_pci_exit()`.
> 
> Signed-off-by: Zheng Huang <hz1624917200@gmail.com>
> 
> ---
>   hw/sd/sdhci-pci.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/hw/sd/sdhci-pci.c b/hw/sd/sdhci-pci.c
> index 5268c0dee5..f5296d58ca 100644
> --- a/hw/sd/sdhci-pci.c
> +++ b/hw/sd/sdhci-pci.c
> @@ -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)
>   

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

>       sdhci_common_unrealize(s);
>       sdhci_uninitfn(s);
> +    qemu_free_irq(s->irq);
>   }

Regardless:
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Philippe Mathieu-Daudé March 31, 2025, 11:20 a.m. UTC | #2
On 28/3/25 10:49, Zheng Huang wrote:
> Hi,
> 
> This patch fixes a memory leak bug in `sdhci_pci_realize()`. `s->irq` is
> not freed in `sdhci_pci_exit()`.
> 
> Signed-off-by: Zheng Huang <hz1624917200@gmail.com>
> 
> ---
>   hw/sd/sdhci-pci.c | 2 ++
>   1 file changed, 2 insertions(+)

Queued to hw-misc, thanks!
diff mbox series

Patch

diff --git a/hw/sd/sdhci-pci.c b/hw/sd/sdhci-pci.c
index 5268c0dee5..f5296d58ca 100644
--- a/hw/sd/sdhci-pci.c
+++ b/hw/sd/sdhci-pci.c
@@ -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)