[PATCH i-g-t v2] tests/intel/gem_exec_capture: fix use of uninitialized hang var

Peter Senna Tschudin me at petersenna.com
Fri Apr 19 17:29:12 UTC 2024


The function main has a variable igt_hang_t hang defined, and it is
currently used by igt_disallow_hang(). However igt_disallow_hang() is
using the variable uninitialized making valgrind unhappy:

 Syscall param ioctl(generic) points to uninitialised byte(s)
    at 0x4ACD3ED: ioctl (in /usr/lib64/libc.so.6)
    by 0x49ACF4F: drmIoctl (xf86drm.c:704)
    by 0x488AF46: __gem_context_set_param (gem_context.c:260)
    by 0x48A540A: igt_disallow_hang (igt_gt.c:236)
    by 0x4013D7: __igt_unique____real_main959 (gem_exec_capture.c:1069)
    by 0x401242: main (gem_exec_capture.c:959)
  Address 0x1fff0001b0 is on thread 1's stack
  in frame #3, created by igt_disallow_hang (igt_gt.c:224)
  Uninitialised value was created by a stack allocation
    at 0x401340: __igt_unique____real_main959 (gem_exec_capture.c:960)

This patch sets the content of the variable hang with the return value
of igt_allow_hang() following what is used elsewhere in the code.  After
this patch valgrind does not complain about the error listed.

Signed-off-by: Peter Senna Tschudin <me at petersenna.com>
Reviewed-by: Kamil Konieczny <kamil.konieczny at linux.intel.com>
---
 tests/intel/gem_exec_capture.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/intel/gem_exec_capture.c b/tests/intel/gem_exec_capture.c
index 57b178f3e..2dc5f94e8 100644
--- a/tests/intel/gem_exec_capture.c
+++ b/tests/intel/gem_exec_capture.c
@@ -983,7 +983,7 @@ igt_main
 
 			gem_context_set_param(fd, &param);
 		}
-		igt_allow_hang(fd, ctx->id, HANG_ALLOW_CAPTURE | HANG_WANT_ENGINE_RESET);
+		hang = igt_allow_hang(fd, ctx->id, HANG_ALLOW_CAPTURE | HANG_WANT_ENGINE_RESET);
 
 		dir = igt_sysfs_open(fd);
 		igt_require(igt_sysfs_set(dir, "error", "Begone!"));
-- 
2.44.0



More information about the igt-dev mailing list