diff options
author | Rohith Iyer <quic_rohiiyer@quicinc.com> | 2022-06-07 14:36:29 -0700 |
---|---|---|
committer | Petri Latvala <petri.latvala@intel.com> | 2022-06-09 10:36:46 +0300 |
commit | 722f32da447888645bbbe6e96728d0f9d2e6d09d (patch) | |
tree | 492b97745e781961b11959b29514b93f6b8202fc | |
parent | 547f7c12716fe8e39573f32585d0377bdc8e7ff8 (diff) |
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 <quic_rohiiyer@quicinc.com>
Reviewed-by: Petri Latvala <petri.latvala@intel.com>
-rw-r--r-- | tests/kms_writeback.c | 8 |
1 files 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; } } |