Commit-ID: 6eeefccdcfc2cc9697562e740bfe6c35fddd4e1c Gitweb: http://git.kernel.org/tip/6eeefccdcfc2cc9697562e740bfe6c35fddd4e1c Author: Patrick Palka <patr...@parcs.ath.cx> AuthorDate: Wed, 12 Mar 2014 18:40:51 -0400 Committer: Arnaldo Carvalho de Melo <a...@redhat.com> CommitDate: Fri, 14 Mar 2014 13:45:54 -0300
perf bench: Fix NULL pointer dereference in "perf bench all" The for_each_bench() macro 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 this NULL pointer dereference when running "perf bench all": [root@ssdandy ~]# perf bench all <SNIP> # Running mem/memset benchmark... # Copying 1MB Bytes ... 2.453675 GB/Sec 12.056327 GB/Sec (with prefault) Segmentation fault (core dumped) [root@ssdandy ~]# Signed-off-by: Patrick Palka <patr...@parcs.ath.cx> Cc: Ingo Molnar <mi...@redhat.com> Cc: Paul Mackerras <pau...@samba.org> Cc: Peter Zijlstra <a.p.zijls...@chello.nl> Link: http://lkml.kernel.org/r/1394664051-6037-1-git-send-email-patr...@parcs.ath.cx Signed-off-by: Arnaldo Carvalho de Melo <a...@redhat.com> --- 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) { -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/