diff mbox series

[4/6] tests/qtest/virtio-iommu-test: Don't pass uninitialized data into qtest_memwrite

Message ID 20241209204427.17763-5-farosas@suse.de (mailing list archive)
State New
Headers show
Series qtest: Fix some memory issues | expand

Commit Message

Fabiano Rosas Dec. 9, 2024, 8:44 p.m. UTC
Valgrind complains about:

Use of uninitialised value of size 8
&
Conditional jump or move depends on uninitialised value(s)

both at:
   at 0x5265931: _itoa_word (_itoa.c:180)
   by 0x527EEC7: __vfprintf_internal (vfprintf-internal.c:1687)
   by 0x528C8B0: __vsprintf_internal (iovsprintf.c:96)
   by 0x526B920: sprintf (sprintf.c:30)
   by 0x1296C7: qtest_memwrite (libqtest.c:1273)
   by 0x193C04: send_map (virtio-iommu-test.c:125)
   by 0x194392: test_attach_detach (virtio-iommu-test.c:214)
   by 0x17BDE7: run_one_test (qos-test.c:181)
   by 0x4B0699D: test_case_run (gtestutils.c:2900)
   by 0x4B0699D: g_test_run_suite_internal (gtestutils.c:2988)
   by 0x4B068B2: g_test_run_suite_internal (gtestutils.c:3005)
   by 0x4B068B2: g_test_run_suite_internal (gtestutils.c:3005)
   by 0x4B068B2: g_test_run_suite_internal (gtestutils.c:3005)
 Uninitialised value was created by a stack allocation
   at 0x193AFD: send_map (virtio-iommu-test.c:103)

Signed-off-by: Fabiano Rosas <farosas@suse.de>
---
 tests/qtest/virtio-iommu-test.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Philippe Mathieu-Daudé Dec. 9, 2024, 9:06 p.m. UTC | #1
On 9/12/24 21:44, Fabiano Rosas wrote:
> Valgrind complains about:
> 
> Use of uninitialised value of size 8
> &
> Conditional jump or move depends on uninitialised value(s)
> 
> both at:
>     at 0x5265931: _itoa_word (_itoa.c:180)
>     by 0x527EEC7: __vfprintf_internal (vfprintf-internal.c:1687)
>     by 0x528C8B0: __vsprintf_internal (iovsprintf.c:96)
>     by 0x526B920: sprintf (sprintf.c:30)
>     by 0x1296C7: qtest_memwrite (libqtest.c:1273)
>     by 0x193C04: send_map (virtio-iommu-test.c:125)
>     by 0x194392: test_attach_detach (virtio-iommu-test.c:214)
>     by 0x17BDE7: run_one_test (qos-test.c:181)
>     by 0x4B0699D: test_case_run (gtestutils.c:2900)
>     by 0x4B0699D: g_test_run_suite_internal (gtestutils.c:2988)
>     by 0x4B068B2: g_test_run_suite_internal (gtestutils.c:3005)
>     by 0x4B068B2: g_test_run_suite_internal (gtestutils.c:3005)
>     by 0x4B068B2: g_test_run_suite_internal (gtestutils.c:3005)
>   Uninitialised value was created by a stack allocation
>     at 0x193AFD: send_map (virtio-iommu-test.c:103)
> 
> Signed-off-by: Fabiano Rosas <farosas@suse.de>
> ---
>   tests/qtest/virtio-iommu-test.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
diff mbox series

Patch

diff --git a/tests/qtest/virtio-iommu-test.c b/tests/qtest/virtio-iommu-test.c
index afb225971d..98ffa27912 100644
--- a/tests/qtest/virtio-iommu-test.c
+++ b/tests/qtest/virtio-iommu-test.c
@@ -105,7 +105,7 @@  static int send_map(QTestState *qts, QVirtioIOMMU *v_iommu,
     QVirtQueue *vq = v_iommu->vq;
     uint64_t ro_addr, wr_addr;
     uint32_t free_head;
-    struct virtio_iommu_req_map req;
+    struct virtio_iommu_req_map req = {};
     size_t ro_size = sizeof(req) - sizeof(struct virtio_iommu_req_tail);
     size_t wr_size = sizeof(struct virtio_iommu_req_tail);
     struct virtio_iommu_req_tail buffer;
@@ -147,7 +147,7 @@  static int send_unmap(QTestState *qts, QVirtioIOMMU *v_iommu,
     QVirtQueue *vq = v_iommu->vq;
     uint64_t ro_addr, wr_addr;
     uint32_t free_head;
-    struct virtio_iommu_req_unmap req;
+    struct virtio_iommu_req_unmap req = {};
     size_t ro_size = sizeof(req) - sizeof(struct virtio_iommu_req_tail);
     size_t wr_size = sizeof(struct virtio_iommu_req_tail);
     struct virtio_iommu_req_tail buffer;