diff mbox

[3/8] assert cpu < CPUS in core/test/run-trace.c

Message ID 1447735147-25957-3-git-send-email-stewart@linux.vnet.ibm.com
State Accepted
Headers show

Commit Message

Stewart Smith Nov. 17, 2015, 4:39 a.m. UTC
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
---
 core/test/run-trace.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/core/test/run-trace.c b/core/test/run-trace.c
index fc08512bf510..fa8a30b12a5a 100644
--- a/core/test/run-trace.c
+++ b/core/test/run-trace.c
@@ -165,6 +165,7 @@  static bool all_done(const bool done[])
 static void test_parallel(void)
 {
 	void *p;
+	unsigned int cpu;
 	unsigned int i, counts[CPUS] = { 0 }, overflows[CPUS] = { 0 };
 	unsigned int repeats[CPUS] = { 0 }, num_overflows[CPUS] = { 0 };
 	bool done[CPUS] = { false };
@@ -224,9 +225,13 @@  static void test_parallel(void)
 			assert(be16_to_cpu(t.repeat.num) <= be16_to_cpu(t.hdr.cpu));
 			repeats[be16_to_cpu(t.hdr.cpu)] += be16_to_cpu(t.repeat.num);
 		} else if (t.hdr.type == 0x70) {
-			done[be16_to_cpu(t.hdr.cpu)] = true;
+			cpu = be16_to_cpu(t.hdr.cpu);
+			assert(cpu < CPUS);
+			done[cpu] = true;
 		} else {
-			counts[be16_to_cpu(t.hdr.cpu)]++;
+			cpu = be16_to_cpu(t.hdr.cpu);
+			assert(cpu < CPUS);
+			counts[cpu]++;
 		}
 	}