[igt-dev] [PATCH i-g-t v1] tests/kms_writeback: Iterate over only non-null pipes
Rohith Iyer
quic_rohiiyer at quicinc.com
Tue Jun 7 21:36:29 UTC 2022
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 at quicinc.com>
---
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..d416d510 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;
}
}
--
2.17.1
More information about the igt-dev
mailing list