From 722f32da447888645bbbe6e96728d0f9d2e6d09d Mon Sep 17 00:00:00 2001 From: Rohith Iyer Date: Tue, 7 Jun 2022 14:36:29 -0700 Subject: tests/kms_writeback: Iterate over only non-null pipes Currently, kms_writeback_get_output iterates over all entries of display->pipes, regardless of if the pipe is valid. This could lead to a null dereference in igt_output_set_pipe() as the loop does not check for null pipes. To avoid this issue, use the for_each_pipe method to iterate over only non-null pipes. Signed-off-by: Rohith Iyer Reviewed-by: Petri Latvala --- tests/kms_writeback.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/kms_writeback.c b/tests/kms_writeback.c index b6c815db..6efc72df 100644 --- a/tests/kms_writeback.c +++ b/tests/kms_writeback.c @@ -110,21 +110,21 @@ static bool check_writeback_config(igt_display_t *display, igt_output_t *output) static igt_output_t *kms_writeback_get_output(igt_display_t *display) { int i; + enum pipe pipe; for (i = 0; i < display->n_outputs; i++) { igt_output_t *output = &display->outputs[i]; - int j; if (output->config.connector->connector_type != DRM_MODE_CONNECTOR_WRITEBACK) continue; - for (j = 0; j < igt_display_get_n_pipes(display); j++) { - igt_output_set_pipe(output, j); + for_each_pipe(display, pipe) { + igt_output_set_pipe(output, pipe); if (check_writeback_config(display, output)) { igt_debug("Using connector %u:%s on pipe %d\n", output->config.connector->connector_id, - output->name, j); + output->name, pipe); return output; } } -- cgit v1.2.3