diff mbox

[i-g-t,v3,3/7] tests/kms_ccs: Prevent segfault if pipe is not supported

Message ID 20170831061810.11773-4-krisman@collabora.co.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Gabriel Krisman Bertazi Aug. 31, 2017, 6:18 a.m. UTC
for_each_plane_on_pipe() indexes bad memory when iterating over an invalid
pipe.  Make sure the pipe exists before trying to use it.  This prevents
the crash below:

root@ideacentre:~# igt-gpu-tools/tests/kms_ccs --r pipe-D-crc-sprite-planes-basic
IGT-Version: 1.19-g59f0e3d182a8 (x86_64) (Linux: 4.13.0-rc6.intel-boxes+x86_64)
Received signal SIGSEGV.
Stack trace:
 #0 [fatal_sig_handler+0x185]
 #1 [killpg+0x40]
 #2 [__real_main485+0x2de]
 #3 [main+0x3f]
 #4 [__libc_start_main+0xf1]
 #5 [_start+0x2a]
 #6 [<unknown>+0x2a]
Subtest pipe-D-crc-sprite-planes-basic: CRASH (0.004s)

Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.co.uk>
---
 tests/kms_ccs.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox

Patch

diff --git a/tests/kms_ccs.c b/tests/kms_ccs.c
index 775c6999699f..73025a1e019f 100644
--- a/tests/kms_ccs.c
+++ b/tests/kms_ccs.c
@@ -503,6 +503,9 @@  igt_main
 
 		data.flags = TEST_CRC;
 		igt_subtest_f("pipe-%s-crc-sprite-planes-basic", pipe_name) {
+
+			igt_display_require_output_on_pipe(&data.display, data.pipe);
+
 			for_each_plane_on_pipe(&data.display, data.pipe, data.plane) {
 				if (data.plane->type == DRM_PLANE_TYPE_PRIMARY)
 					continue;