mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] perf bench: Fix NULL pointer dereference in "perf bench all"
@ 2014-03-12 22:40 Patrick Palka
  2014-03-13 14:34 ` Arnaldo Carvalho de Melo
  2014-03-18  8:29 ` [tip:perf/urgent] perf bench: Fix NULL pointer dereference in " perf " tip-bot for Patrick Palka
  0 siblings, 2 replies; 5+ messages in thread
From: Patrick Palka @ 2014-03-12 22:40 UTC (permalink / raw)
  To: linux-kernel; +Cc: acme, mingo, paulus, a.p.zijlstra, Patrick Palka

for_each_bench() must check that the "benchmarks" field of a collection
is not NULL before dereferencing it because the "all" collection in
particular has a NULL "benchmarks" field (signifying that it has no
benchmarks to iterate over).

This fixes a NULL pointer dereference when running "perf bench all".

Signed-off-by: Patrick Palka <patrick@parcs.ath.cx>
---
 tools/perf/builtin-bench.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/builtin-bench.c b/tools/perf/builtin-bench.c
index e47f90c..8a987d2 100644
--- a/tools/perf/builtin-bench.c
+++ b/tools/perf/builtin-bench.c
@@ -76,7 +76,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)
 {
-- 
1.9.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-03-18  8:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-12 22:40 [PATCH] perf bench: Fix NULL pointer dereference in "perf bench all" Patrick Palka
2014-03-13 14:34 ` Arnaldo Carvalho de Melo
2014-03-13 14:47   ` Patrick Palka
2014-03-13 18:18     ` Arnaldo Carvalho de Melo
2014-03-18  8:29 ` [tip:perf/urgent] perf bench: Fix NULL pointer dereference in " perf " tip-bot for Patrick Palka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome