diff mbox

[6/7] sna_video_sprite: add asserts to catch invalid pipe#

Message ID 1455294689-29249-7-git-send-email-martin.peres@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Martin Peres Feb. 12, 2016, 4:31 p.m. UTC
Caught by Klockwork. This will be enough to catch those issues during
bringup.

Signed-off-by: Martin Peres <martin.peres@linux.intel.com>
---
 src/sna/sna_video_sprite.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Chris Wilson Feb. 12, 2016, 4:45 p.m. UTC | #1
On Fri, Feb 12, 2016 at 06:31:28PM +0200, Martin Peres wrote:
> Caught by Klockwork. This will be enough to catch those issues during
> bringup.

But you just said that klockwork didn't find a bug... :-p

I did contemplate having this stored on the CRTC instead.

Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris
diff mbox

Patch

diff --git a/src/sna/sna_video_sprite.c b/src/sna/sna_video_sprite.c
index 9e85049..ae08ef7 100644
--- a/src/sna/sna_video_sprite.c
+++ b/src/sna/sna_video_sprite.c
@@ -86,6 +86,7 @@  static int sna_video_sprite_stop(ddStopVideo_ARGS)
 		int pipe;
 
 		pipe = sna_crtc_pipe(crtc);
+		assert(pipe < ARRAY_SIZE(video->bo));
 		if (video->bo[pipe] == NULL)
 			continue;
 
@@ -260,6 +261,7 @@  sna_video_sprite_show(struct sna *sna,
 		video->color_key_changed &= ~(1 << pipe);
 	}
 
+	assert(pipe < ARRAY_SIZE(video->bo));
 	if (video->bo[pipe] == frame->bo)
 		return true;
 
@@ -415,6 +417,7 @@  static int sna_video_sprite_put_image(ddPutImage_ARGS)
 		RegionIntersect(&reg, &reg, &clip);
 		if (RegionNil(&reg)) {
 off:
+			assert(pipe < ARRAY_SIZE(video->bo));
 			if (video->bo[pipe]) {
 				struct local_mode_set_plane s;
 				memset(&s, 0, sizeof(s));