]> www.infradead.org Git - users/dwmw2/linux.git/commit
perf stat: Avoid segfaults caused by negated options
authorMichael Petlan <mpetlan@redhat.com>
Mon, 10 Dec 2018 16:00:04 +0000 (11:00 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 26 Jan 2019 08:20:48 +0000 (09:20 +0100)
commit77d1d83ba54b6cf62d2dae9c93b7e098793f8811
treed151c9834c9f7c32e2f38732cf2f359a8056c8f8
parent00ac60761035c2b3b36d28f405e9e2dcb2e43388
perf stat: Avoid segfaults caused by negated options

[ Upstream commit 51433ead1460fb3f46e1c34f68bb22fd2dd0f5d0 ]

Some 'perf stat' options do not make sense to be negated (event,
cgroup), some do not have negated path implemented (metrics). Due to
that, it is better to disable the "no-" prefix for them, since
otherwise, the later opt-parsing segfaults.

Before:

  $ perf stat --no-metrics -- ls
  Segmentation fault (core dumped)

After:

  $ perf stat --no-metrics -- ls
   Error: option `no-metrics' isn't available
   Usage: perf stat [<options>] [<command>]

Signed-off-by: Michael Petlan <mpetlan@redhat.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
LPU-Reference: 1485912065.62416880.1544457604340.JavaMail.zimbra@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/perf/builtin-stat.c