diff mbox

[i-g-t,3/5] lib/igt_kms: Fix possible out-of-bounds access

Message ID 1487354070-14487-3-git-send-email-brian.starkey@arm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Brian Starkey Feb. 17, 2017, 5:54 p.m. UTC
If there's no primary plane, pipe->plane_primary == -1, and the assert
meant to check that it's valid will access pipe->planes[-1].

Fix that to check that pipe->plane_primary has been set instead.

Fixes: 36656239ef96 lib/igt_kms: Implement dynamic plane count support
Signed-off-by: Brian Starkey <brian.starkey@arm.com>
---
 lib/igt_kms.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Robert Foss Feb. 19, 2017, 8:42 p.m. UTC | #1
On 2017-02-17 12:54 PM, Brian Starkey wrote:
> If there's no primary plane, pipe->plane_primary == -1, and the assert
> meant to check that it's valid will access pipe->planes[-1].
>
> Fix that to check that pipe->plane_primary has been set instead.

Reviewed-by: Robert Foss <robert.foss@collabora.com>


Rob.

>
> Fixes: 36656239ef96 lib/igt_kms: Implement dynamic plane count support
> Signed-off-by: Brian Starkey <brian.starkey@arm.com>
> ---
>  lib/igt_kms.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> index 783c891aebf1..45c90c71f301 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -1820,9 +1820,9 @@ void igt_display_init(igt_display_t *display, int drm_fd)
>
>  		/*
>  		 * At the bare minimum, we should expect to have a primary
> -		 * plane
> +		 * plane, and it must be in slot 0.
>  		 */
> -		igt_assert(pipe->planes[pipe->plane_primary].drm_plane);
> +		igt_assert_eq(pipe->plane_primary, 0);
>
>  		if (display->has_cursor_plane) {
>  			/*
>
diff mbox

Patch

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 783c891aebf1..45c90c71f301 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -1820,9 +1820,9 @@  void igt_display_init(igt_display_t *display, int drm_fd)
 
 		/*
 		 * At the bare minimum, we should expect to have a primary
-		 * plane
+		 * plane, and it must be in slot 0.
 		 */
-		igt_assert(pipe->planes[pipe->plane_primary].drm_plane);
+		igt_assert_eq(pipe->plane_primary, 0);
 
 		if (display->has_cursor_plane) {
 			/*