tests/qtest/migration: Initialize buffer in probe_o_direct_support
authorFabiano Rosas <farosas@suse.de>
Mon, 9 Dec 2024 20:44:23 +0000 (17:44 -0300)
committerFabiano Rosas <farosas@suse.de>
Thu, 2 Jan 2025 19:00:50 +0000 (16:00 -0300)
Valgrind complains about the probe_o_direct_support() function reading
from an uninitialized buffer. For probing O_DIRECT support we don't
actually need to write to the file, just make sure the pwrite call
doesn't reject the write. Still, write zeroes to the buffer to
suppress the warning.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Peter Xu <peterx@redhat.com>
Message-Id: <20241209204427.17763-3-farosas@suse.de>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
tests/qtest/migration/migration-util.c

index 525bf1eed420a65e1663af1b1d365746c3257457..401fe27f0024e1c83d4b23c88aae96f4949eb594 100644 (file)
@@ -284,6 +284,7 @@ bool probe_o_direct_support(const char *tmpfs)
 
     buf = qemu_try_memalign(len, len);
     g_assert(buf);
+    memset(buf, 0, len);
 
     ret = pwrite(fd, buf, len, offset);
     unlink(filename);