Commit 02292db33e for qemu.org
commit 02292db33e050fc68eec423c27d459ac4c28694d
Author: Marc-André Lureau <marcandre.lureau@redhat.com>
Date: Wed Oct 21 10:30:09 2026 +0400
tests/xilinx-zynq-sdhci-test: fix GIOChannel leak
Reported by ASAN.
Fixes: 255c627c645b ("qtest: add xilinx-zynq SDHCI sdma test")
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Tested-by: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
diff --git a/tests/qtest/xilinx-zynq-sdhci-test.c b/tests/qtest/xilinx-zynq-sdhci-test.c
index 7957358cf5..42e1b8f46e 100644
--- a/tests/qtest/xilinx-zynq-sdhci-test.c
+++ b/tests/qtest/xilinx-zynq-sdhci-test.c
@@ -58,10 +58,10 @@ static QTestState *setup_sd_card(void)
static void write_pattern_to_image(size_t offset, size_t len)
{
- gchar *buf = g_malloc(len);
+ g_autofree gchar *buf = g_malloc(len);
+ g_autoptr(GIOChannel) chan = NULL;
GError *err = NULL;
gsize bytes_written;
- GIOChannel *chan;
for (size_t i = 0; i < len; i++) {
buf[i] = (i * 13 + 7) & 0xff;
@@ -78,8 +78,6 @@ static void write_pattern_to_image(size_t offset, size_t len)
g_assert_cmpint(bytes_written, ==, len);
g_io_channel_shutdown(chan, TRUE, &err);
g_assert_no_error(err);
-
- g_free(buf);
}
static void wait_for_block_count(QTestState *qts, uint16_t expected)