All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	David Ahern <dsahern@gmail.com>, Jiri Olsa <jolsa@kernel.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Wang Nan <wangnan0@huawei.com>
Subject: [PATCH 09/14] perf probe: Avoid accessing uninitialized 'map' variable
Date: Wed, 15 Feb 2017 16:04:19 -0300	[thread overview]
Message-ID: <20170215190424.18687-10-acme@kernel.org> (raw)
In-Reply-To: <20170215190424.18687-1-acme@kernel.org>

From: Arnaldo Carvalho de Melo <acme@redhat.com>

Genuine problem detected with clang, the warnings are spot on:

  util/probe-event.c:2079:7: error: variable 'map' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
                  if (addr) {
                      ^~~~
  util/probe-event.c:2094:6: note: uninitialized use occurs here
          if (map && !is_kprobe) {
              ^~~
  util/probe-event.c:2079:3: note: remove the 'if' if its condition is always true
                  if (addr) {
                  ^~~~~~~~~~
  util/probe-event.c:2075:8: error: variable 'map' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]
                          if (kernel_get_symbol_address_by_name(tp->symbol,
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  util/probe-event.c:2094:6: note: uninitialized use occurs here
          if (map && !is_kprobe) {
              ^~~
  util/probe-event.c:2075:4: note: remove the 'if' if its condition is always false
                          if (kernel_get_symbol_address_by_name(tp->symbol,
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  util/probe-event.c:2064:17: note: initialize the variable 'map' to silence this warning
          struct map *map;
                         ^
                          = NULL

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-m3501el55i10hctfbmi2qxzr@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/probe-event.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 2c1bca240597..35f5b7b7715c 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -2061,7 +2061,7 @@ static int find_perf_probe_point_from_map(struct probe_trace_point *tp,
 					  bool is_kprobe)
 {
 	struct symbol *sym = NULL;
-	struct map *map;
+	struct map *map = NULL;
 	u64 addr = tp->address;
 	int ret = -ENOENT;
 
-- 
2.9.3

  parent reply	other threads:[~2017-02-15 19:06 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-15 19:04 [GIT PULL 00/14] perf/core clang fixes Arnaldo Carvalho de Melo
2017-02-15 19:04 ` [PATCH 01/14] tools: Suppress request for warning options not existent in clang Arnaldo Carvalho de Melo
2017-02-15 19:04 ` [PATCH 02/14] tools: Set the maximum optimization level according to the compiler being used Arnaldo Carvalho de Melo
2017-02-15 19:04 ` [PATCH 03/14] tools lib subcmd: Make it an error to pass a signed value to OPTION_UINTEGER Arnaldo Carvalho de Melo
2017-02-15 19:04 ` [PATCH 04/14] Revert "perf bench futex: Sanitize numeric parameters" Arnaldo Carvalho de Melo
2017-02-15 19:04 ` [PATCH 05/14] perf bench numa: Make sure dprintf() is not defined Arnaldo Carvalho de Melo
2017-02-15 19:04 ` [PATCH 06/14] perf tests: Synthesize struct instead of using field after variable sized type Arnaldo Carvalho de Melo
2017-02-15 19:04 ` [PATCH 07/14] perf record: Do not put a variable sized type not at the end of a struct Arnaldo Carvalho de Melo
2017-02-15 19:04 ` [PATCH 08/14] perf tools: " Arnaldo Carvalho de Melo
2017-02-15 19:04 ` Arnaldo Carvalho de Melo [this message]
2017-02-15 19:04 ` [PATCH 10/14] perf evsel: " Arnaldo Carvalho de Melo
2017-02-15 19:04 ` [PATCH 11/14] perf intel pt decoder: clang has no -Wno-override-init Arnaldo Carvalho de Melo
2017-02-15 19:04 ` [PATCH 12/14] perf tools: Be consistent on the type of map->symbols[] interator Arnaldo Carvalho de Melo
2017-02-15 19:04 ` [PATCH 13/14] perf pmu: Fix check for unset alias->unit array Arnaldo Carvalho de Melo
2017-02-15 19:04 ` [PATCH 14/14] perf tools: Add missing parse_events_error() prototype Arnaldo Carvalho de Melo
2017-02-16 19:54 ` [GIT PULL 00/14] perf/core clang fixes Ingo Molnar

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=20170215190424.18687-10-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=adrian.hunter@intel.com \
    --cc=dsahern@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=wangnan0@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.