diff --git a/tools/perf/builtin-bench.c b/tools/perf/builtin-bench.c
index f600b74216da4b876ee0e5f127eae3eab347d447..1e6e77710545afc472eae5c0f5e5a63f5ec432d1 100644
--- a/tools/perf/builtin-bench.c
+++ b/tools/perf/builtin-bench.c
@@ -86,7 +86,7 @@ static struct collection collections[] = {
 
 /* Iterate over all benchmarks within a collection: */
 #define for_each_bench(coll, bench) \
-	for (bench = coll->benchmarks; bench->name; bench++)
+	for (bench = coll->benchmarks; bench && bench->name; bench++)
 
 static void dump_benchmarks(struct collection *coll)
 {