Skip to contentSkip to conversation

selftests/net: rxtimestamp: Fix an off by one

PATCH Applied Dan Carpenter 2 participants 2 messages Oct 5, 2017 – Oct 6, 2017

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests/net: rxtimestamp: Fix an off by one

The > should be >= so that we don't write one element beyond the end of the array.

Fixes 16e781224198 ("selftests/net: Add a test to validate behavior of rx timestamps")
tools/testing/selftests/networking/timestamping/rxtimestamp.c +1 -1
index 00f286661dcd..dd4162fc0419 100644
@@ -341,7 +341,7 @@ int main(int argc, char **argv)
 			return 0;
 		case 'n':
 			t = atoi(optarg);
-			if (t > ARRAY_SIZE(test_cases))
+			if (t >= ARRAY_SIZE(test_cases))
 				error(1, 0, "Invalid test case: %d", t);
 			all_tests = false;
 			test_cases[t].enabled = true;
maintainer Applied
#1 lore raw

From: Dan Carpenter <[email protected]>
Date: Thu, 5 Oct 2017 15:53:47 +0300

Quoted 5 lines

The > should be >= so that we don't write one element beyond the end of the array.

Fixes 16e781224198 ("selftests/net: Add a test to validate behavior of rx timestamps")

Applied.