[Qemu-devel] [PATCH 6/6] sdhci-test: fix leaks

Marc-André Lureau posted 6 patches 7 years, 8 months ago
[Qemu-devel] [PATCH 6/6] sdhci-test: fix leaks
Posted by Marc-André Lureau 7 years, 8 months ago
Fix the following ASAN reports:

==20125==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 24 byte(s) in 1 object(s) allocated from:
    #0 0x7f0faea03a38 in __interceptor_calloc (/lib64/libasan.so.4+0xdea38)
    #1 0x7f0fae450f75 in g_malloc0 ../glib/gmem.c:124
    #2 0x562fffd526fc in machine_start /home/elmarco/src/qemu/tests/sdhci-test.c:180

Indirect leak of 152 byte(s) in 1 object(s) allocated from:
    #0 0x7f0faea03850 in malloc (/lib64/libasan.so.4+0xde850)
    #1 0x7f0fae450f0c in g_malloc ../glib/gmem.c:94
    #2 0x562fffd5d21d in qpci_init_pc /home/elmarco/src/qemu/tests/libqos/pci-pc.c:122

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 tests/sdhci-test.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tests/sdhci-test.c b/tests/sdhci-test.c
index 493023fd0c..8a7099398c 100644
--- a/tests/sdhci-test.c
+++ b/tests/sdhci-test.c
@@ -209,8 +209,10 @@ static QSDHCI *machine_start(const struct sdhci_t *test)
 
 static void machine_stop(QSDHCI *s)
 {
+    qpci_free_pc(s->pci.bus);
     g_free(s->pci.dev);
     qtest_quit(global_qtest);
+    g_free(s);
 }
 
 static void test_machine(const void *data)
-- 
2.16.1.73.g5832b7e9f2


Re: [Qemu-devel] [PATCH 6/6] sdhci-test: fix leaks
Posted by Philippe Mathieu-Daudé 7 years, 8 months ago
On 02/15/2018 06:25 PM, Marc-André Lureau wrote:
> Fix the following ASAN reports:
> 
> ==20125==ERROR: LeakSanitizer: detected memory leaks
> 
> Direct leak of 24 byte(s) in 1 object(s) allocated from:
>     #0 0x7f0faea03a38 in __interceptor_calloc (/lib64/libasan.so.4+0xdea38)
>     #1 0x7f0fae450f75 in g_malloc0 ../glib/gmem.c:124
>     #2 0x562fffd526fc in machine_start /home/elmarco/src/qemu/tests/sdhci-test.c:180
> 
> Indirect leak of 152 byte(s) in 1 object(s) allocated from:
>     #0 0x7f0faea03850 in malloc (/lib64/libasan.so.4+0xde850)
>     #1 0x7f0fae450f0c in g_malloc ../glib/gmem.c:94
>     #2 0x562fffd5d21d in qpci_init_pc /home/elmarco/src/qemu/tests/libqos/pci-pc.c:122

Oops my bad, thanks!

> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
>  tests/sdhci-test.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/tests/sdhci-test.c b/tests/sdhci-test.c
> index 493023fd0c..8a7099398c 100644
> --- a/tests/sdhci-test.c
> +++ b/tests/sdhci-test.c
> @@ -209,8 +209,10 @@ static QSDHCI *machine_start(const struct sdhci_t *test)
>  
>  static void machine_stop(QSDHCI *s)
>  {
> +    qpci_free_pc(s->pci.bus);
>      g_free(s->pci.dev);
>      qtest_quit(global_qtest);
> +    g_free(s);
>  }
>  
>  static void test_machine(const void *data)
>