[PATCH] lib: interval_tree_test: validate benchmark parameters
From: Samuel Moelius
Date: Mon Jun 08 2026 - 21:01:18 EST
The interval tree runtime test accepts module parameters that are later
used as divisors while generating randomized intervals and while
reporting average timings. For example, max_endpoint=1 makes the
generated interval end value zero and the next modulo operation divides
by that zero value.
Reject non-positive counts and require max_endpoint to provide at least
one non-zero generated endpoint before the test allocates state or
starts the benchmark.
Assisted-by: Codex:gpt-5.5-cyber-preview
Signed-off-by: Samuel Moelius <sam.moelius@xxxxxxxxxxxxxxx>
---
lib/interval_tree_test.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/lib/interval_tree_test.c b/lib/interval_tree_test.c
index 16200feacbf3..58f6f3a307f4 100644
--- a/lib/interval_tree_test.c
+++ b/lib/interval_tree_test.c
@@ -311,6 +311,27 @@ static inline int span_iteration_check(void) {return 0; }
static int interval_tree_test_init(void)
{
+ if (nnodes <= 0) {
+ pr_warn("nnodes must be positive\n");
+ return -EINVAL;
+ }
+ if (nsearches <= 0) {
+ pr_warn("nsearches must be positive\n");
+ return -EINVAL;
+ }
+ if (perf_loops <= 0) {
+ pr_warn("perf_loops must be positive\n");
+ return -EINVAL;
+ }
+ if (search_loops <= 0) {
+ pr_warn("search_loops must be positive\n");
+ return -EINVAL;
+ }
+ if (max_endpoint < 2) {
+ pr_warn("max_endpoint must be at least 2\n");
+ return -EINVAL;
+ }
+
nodes = kmalloc_objs(struct interval_tree_node, nnodes);
if (!nodes)
return -ENOMEM;
--
2.43.0