From: tip-bot for Yunlong Song <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: paulus@samba.org, wangnan0@huawei.com, mingo@kernel.org,
yunlong.song@huawei.com, tglx@linutronix.de, acme@redhat.com,
a.p.zijlstra@chello.nl, linux-kernel@vger.kernel.org,
hpa@zytor.com
Subject: [tip:perf/core] perf tools: Fix a bug of segmentation fault
Date: Wed, 18 Feb 2015 10:41:32 -0800 [thread overview]
Message-ID: <tip-3a03005ff9445834f3d3b577a11bcbdbdf7a89cf@git.kernel.org> (raw)
In-Reply-To: <1423833115-11199-5-git-send-email-yunlong.song@huawei.com>
Commit-ID: 3a03005ff9445834f3d3b577a11bcbdbdf7a89cf
Gitweb: http://git.kernel.org/tip/3a03005ff9445834f3d3b577a11bcbdbdf7a89cf
Author: Yunlong Song <yunlong.song@huawei.com>
AuthorDate: Fri, 13 Feb 2015 21:11:52 +0800
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 13 Feb 2015 11:38:43 -0300
perf tools: Fix a bug of segmentation fault
Fix the 'segmentation fault' bug of 'perf list --list-cmds', which also
happens in other cases (e.g. record, report ...). This bug happens when
there are no cmds to list at all.
Example:
Before this patch:
$ perf list --list-cmds
Segmentation fault
$
After this patch:
$ perf list --list-cmds
$
As shown above, the result prints nothing rather than a segmentation
fault. The null result means 'perf list' has no cmds to display at this
time.
Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1423833115-11199-5-git-send-email-yunlong.song@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/parse-options.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/tools/perf/util/parse-options.c b/tools/perf/util/parse-options.c
index 4a015f7..4ee9a86 100644
--- a/tools/perf/util/parse-options.c
+++ b/tools/perf/util/parse-options.c
@@ -510,8 +510,10 @@ int parse_options_subcommand(int argc, const char **argv, const struct option *o
}
exit(130);
case PARSE_OPT_LIST_SUBCMDS:
- for (int i = 0; subcommands[i]; i++)
- printf("%s ", subcommands[i]);
+ if (subcommands) {
+ for (int i = 0; subcommands[i]; i++)
+ printf("%s ", subcommands[i]);
+ }
exit(130);
default: /* PARSE_OPT_UNKNOWN */
if (ctx.argv[0][1] == '-') {
next prev parent reply other threads:[~2015-02-18 18:41 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-13 13:11 [PATCH 0/7] perf list: make some improvements and fixes Yunlong Song
2015-02-13 13:11 ` [PATCH 1/7] perf list: clean up the printing functions of hardware/software events Yunlong Song
2015-02-13 13:11 ` [PATCH 2/7] perf list: sort the output of 'perf list' to view more clearly Yunlong Song
2015-02-13 14:45 ` Arnaldo Carvalho de Melo
2015-02-13 14:49 ` Arnaldo Carvalho de Melo
2015-02-15 10:19 ` Yunlong Song
2015-02-15 10:11 ` Yunlong Song
2015-02-13 13:11 ` [PATCH 3/7] perf list: fix some inaccuracy problem when parsing the argument Yunlong Song
2015-02-13 13:11 ` [PATCH 4/7] perf list: fix a bug of segmentation fault Yunlong Song
2015-02-18 18:41 ` tip-bot for Yunlong Song [this message]
2015-02-13 13:11 ` [PATCH 5/7] perf list: avoid confusion of perf output and the next command prompt Yunlong Song
2015-02-13 14:52 ` Arnaldo Carvalho de Melo
2015-02-15 10:01 ` Yunlong Song
2015-02-13 13:11 ` [PATCH 6/7] perf list: extend raw-dump to certain kind of events Yunlong Song
2015-02-13 14:55 ` Arnaldo Carvalho de Melo
2015-02-15 10:05 ` Yunlong Song
2015-02-13 13:11 ` [PATCH 7/7] perf list: place the guiding text in its right position Yunlong Song
2015-02-18 18:42 ` [tip:perf/core] perf list: Place the header " tip-bot for Yunlong Song
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tip-3a03005ff9445834f3d3b577a11bcbdbdf7a89cf@git.kernel.org \
--to=tipbot@zytor.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@redhat.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=paulus@samba.org \
--cc=tglx@linutronix.de \
--cc=wangnan0@huawei.com \
--cc=yunlong.song@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.