From: Mika Kuoppala Date: Thu, 10 Apr 2014 14:51:39 +0000 (+0300) Subject: tests/gem_reset_stats: fix length check in inject_hang X-Git-Tag: intel-gpu-tools-1.7~158 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=99b8f807010483128f10f7934a864c78b4438b34;p=profile%2Fextras%2Fintel-gpu-tools.git tests/gem_reset_stats: fix length check in inject_hang To avoid writing past the batch end. Signed-off-by: Mika Kuoppala --- diff --git a/tests/gem_reset_stats.c b/tests/gem_reset_stats.c index c69059b..c227798 100644 --- a/tests/gem_reset_stats.c +++ b/tests/gem_reset_stats.c @@ -295,7 +295,7 @@ static int inject_hang_ring(int fd, int ctx, int ring, bool ignore_ban_error) for (i = 0; i < ITEMS; i++) buf[i] = MI_NOOP; - roff = random() % (ITEMS - cmd_len); + roff = random() % (ITEMS - cmd_len - 1); buf[roff] = MI_BATCH_BUFFER_START | (cmd_len - 2); buf[roff + 1] = (gtt_off & 0xfffffffc) + (roff << 2); if (cmd_len == 3)