On 02/07/2017 08:51 AM, Marc-André Lureau wrote:
> Spotted by ASAN.
> 
> Cc: John Snow <js...@redhat.com>
> Signed-off-by: Marc-André Lureau <marcandre.lur...@redhat.com>
> ---
>  tests/ide-test.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/tests/ide-test.c b/tests/ide-test.c
> index fb541f88b5..2fa97bc36b 100644
> --- a/tests/ide-test.c
> +++ b/tests/ide-test.c
> @@ -339,6 +339,7 @@ static void test_bmdma_simple_rw(void)
>      g_assert(memcmp(buf, cmpbuf, len) == 0);
>  
>  
> +    free_pci_device(dev);
>      g_free(buf);
>      g_free(cmpbuf);
>  }
> @@ -369,6 +370,7 @@ static void test_bmdma_short_prdt(void)
>                                prdt, ARRAY_SIZE(prdt), NULL);
>      g_assert_cmphex(status, ==, 0);
>      assert_bit_clear(qpci_io_readb(dev, ide_bar, reg_status), DF | ERR);
> +    free_pci_device(dev);
>  }
>  
>  static void test_bmdma_one_sector_short_prdt(void)
> @@ -398,6 +400,7 @@ static void test_bmdma_one_sector_short_prdt(void)
>                                prdt, ARRAY_SIZE(prdt), NULL);
>      g_assert_cmphex(status, ==, 0);
>      assert_bit_clear(qpci_io_readb(dev, ide_bar, reg_status), DF | ERR);
> +    free_pci_device(dev);
>  }
>  
>  static void test_bmdma_long_prdt(void)
> @@ -426,6 +429,7 @@ static void test_bmdma_long_prdt(void)
>                                prdt, ARRAY_SIZE(prdt), NULL);
>      g_assert_cmphex(status, ==, BM_STS_INTR);
>      assert_bit_clear(qpci_io_readb(dev, ide_bar, reg_status), DF | ERR);
> +    free_pci_device(dev);
>  }
>  
>  static void test_bmdma_no_busmaster(void)
> @@ -449,6 +453,7 @@ static void test_bmdma_no_busmaster(void)
>       * in practice. At least we want to be aware of any changes. */
>      g_assert_cmphex(status, ==, BM_STS_ACTIVE | BM_STS_INTR);
>      assert_bit_clear(qpci_io_readb(dev, ide_bar, reg_status), DF | ERR);
> +    free_pci_device(dev);
>  }
>  
>  static void test_bmdma_setup(void)
> @@ -525,6 +530,7 @@ static void test_identify(void)
>      assert_bit_set(buf[85], 0x20);
>  
>      ide_test_quit();
> +    free_pci_device(dev);
>  }
>  
>  /*
> @@ -562,6 +568,7 @@ static void make_dirty(uint8_t device)
>      assert_bit_clear(qpci_io_readb(dev, ide_bar, reg_status), DF | ERR);
>  
>      g_free(buf);
> +    free_pci_device(dev);
>  }
>  
>  static void test_flush(void)
> @@ -608,6 +615,7 @@ static void test_flush(void)
>      assert_bit_clear(data, BSY | DF | ERR | DRQ);
>  
>      ide_test_quit();
> +    free_pci_device(dev);
>  }
>  
>  static void test_retry_flush(const char *machine)
> @@ -658,6 +666,7 @@ static void test_retry_flush(const char *machine)
>      assert_bit_clear(data, BSY | DF | ERR | DRQ);
>  
>      ide_test_quit();
> +    free_pci_device(dev);
>  }
>  
>  static void test_flush_nodev(void)
> @@ -675,6 +684,7 @@ static void test_flush_nodev(void)
>  
>      /* Just testing that qemu doesn't crash... */
>  
> +    free_pci_device(dev);
>      ide_test_quit();
>  }
>  
> @@ -741,6 +751,7 @@ static uint8_t ide_wait_clear(uint8_t flag)
>      while (true) {
>          data = qpci_io_readb(dev, ide_bar, reg_status);
>          if (!(data & flag)) {
> +            free_pci_device(dev);
>              return data;
>          }
>          if (difftime(time(NULL), st) > 5.0) {
> @@ -850,6 +861,7 @@ static void cdrom_pio_impl(int nblocks)
>      g_free(pattern);
>      g_free(rx);
>      test_bmdma_teardown();
> +    free_pci_device(dev);
>  }
>  
>  static void test_cdrom_pio(void)
> 

Reviewed-by: John Snow <js...@redhat.com>

And since valgrind yelled at me when I went to test it, I sent a related
patch out too.

--js

Reply via email to