From 3ccce99281eaef560334300bb025b770b49ed9b1 Mon Sep 17 00:00:00 2001 From: Lyude Date: Mon, 12 Dec 2016 13:25:39 -0500 Subject: igt_kms: Dynamically allocate igt_display->pipes Many GPUs have more then 3 pipes available, so hard limiting this to I915_MAX_PIPES prevents us from using anything that relies on igt_display_init() on non-intel systems (since we end up writing out of bounds and seg faulting). Fix this by dynamically allocating igt_display->pipes using the number of pipes we've detected on the GPU. Signed-off-by: Lyude Reviewed-by: Abdiel Janulgue --- lib/igt_kms.c | 2 ++ lib/igt_kms.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/igt_kms.c b/lib/igt_kms.c index 0e7b8e88..5312f8d8 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -1345,6 +1345,7 @@ void igt_display_init(igt_display_t *display, int drm_fd) * hardware and cannot change of time (for now, at least). */ display->n_pipes = resources->count_crtcs; + display->pipes = calloc(sizeof(igt_pipe_t), display->n_pipes); drmSetClientCap(drm_fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1); is_atomic = drmSetClientCap(drm_fd, DRM_CLIENT_CAP_ATOMIC, 1); @@ -1557,6 +1558,7 @@ void igt_display_fini(igt_display_t *display) for (i = 0; i < display->n_outputs; i++) igt_output_fini(&display->outputs[i]); free(display->outputs); + free(display->pipes); display->outputs = NULL; } diff --git a/lib/igt_kms.h b/lib/igt_kms.h index 0dcb325c..5234f6c1 100644 --- a/lib/igt_kms.h +++ b/lib/igt_kms.h @@ -310,7 +310,7 @@ struct igt_display { int n_outputs; unsigned long pipes_in_use; igt_output_t *outputs; - igt_pipe_t pipes[I915_MAX_PIPES]; + igt_pipe_t *pipes; bool has_cursor_plane; bool is_atomic; }; -- cgit v1.2.3