Leo Yan
363bbaef63
perf map: Fix potential NULL pointer dereference found by smatch tool
...
Based on the following report from Smatch, fix the potential NULL
pointer dereference check.
tools/perf/util/map.c:479
map__fprintf_srccode() error: we previously assumed 'state' could be
null (see line 466)
tools/perf/util/map.c
465 /* Avoid redundant printing */
466 if (state &&
467 state->srcfile &&
468 !strcmp(state->srcfile, srcfile) &&
469 state->line == line) {
470 free(srcfile);
471 return 0;
472 }
473
474 srccode = find_sourceline(srcfile, line, &len);
475 if (!srccode)
476 goto out_free_line;
477
478 ret = fprintf(fp, "|%-8d %.*s", line, len, srccode);
479 state->srcfile = srcfile;
^^^^^^^
480 state->line = line;
^^^^^^^
This patch validates 'state' pointer before access its elements.
Signed-off-by: Leo Yan <leo.yan@linaro.org>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
Cc: Alexios Zavras <alexios.zavras@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Changbin Du <changbin.du@intel.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Davidlohr Bueso <dave@stgolabs.net>
Cc: Eric Saint-Etienne <eric.saint.etienne@oracle.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Song Liu <songliubraving@fb.com>
Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Thomas Richter <tmricht@linux.ibm.com>
Cc: linux-arm-kernel@lists.infradead.org
Fixes: dd2e18e9ac20 ("perf tools: Support 'srccode' output")
Link: http://lkml.kernel.org/r/20190702103420.27540-8-leo.yan@linaro.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2019-07-09 09:33:55 -03:00
..
2019-07-08 18:04:41 +02:00
2019-05-02 16:00:20 -04:00
2019-07-02 16:08:16 -03:00
2019-06-05 09:48:55 -03:00
2019-03-06 09:45:37 -03:00
2019-07-07 17:53:09 -03:00
2019-07-02 16:08:16 -03:00
2019-06-05 17:37:14 +02:00
2019-06-25 08:47:10 -03:00
2019-07-09 09:33:54 -03:00
2019-05-28 18:37:43 -03:00
2019-07-06 16:59:11 -03:00
2019-07-09 09:33:55 -03:00
2019-02-14 15:18:08 -03:00
2019-05-15 16:36:46 -03:00
2018-11-21 22:39:55 -03:00
2019-02-22 16:52:07 -03:00
2019-02-22 16:52:07 -03:00
2019-03-06 18:15:24 -03:00
2018-12-18 12:24:00 -03:00
2019-07-02 13:20:51 -03:00
2019-02-22 16:52:07 -03:00
2019-06-05 17:37:16 +02:00
2018-12-17 14:59:18 -03:00
2019-05-15 16:36:49 -03:00
2019-06-05 17:30:26 +02:00
2019-06-25 21:02:47 -03:00
2019-02-22 16:52:07 -03:00
2019-04-01 14:49:25 -03:00
2019-02-22 16:52:07 -03:00
2019-02-22 16:52:07 -03:00
2019-05-30 11:26:35 -07:00
2019-06-10 15:50:01 -03:00
2019-06-26 11:31:43 -03:00
2019-06-25 21:02:47 -03:00
2019-07-03 00:13:25 -03:00
2019-07-09 09:33:54 -03:00
2019-06-05 17:37:17 +02:00
2019-07-09 09:33:54 -03:00
2019-07-09 09:33:55 -03:00
2019-04-01 15:18:10 -03:00
2019-03-11 16:33:19 -03:00
2019-06-25 21:02:47 -03:00
2018-09-19 14:53:36 -03:00
2019-01-21 11:01:18 +01:00
2018-08-20 08:54:58 -03:00
2019-07-07 17:53:09 -03:00
2019-06-03 11:56:35 +02:00
2019-07-01 22:50:40 -03:00
2019-01-08 13:28:13 -03:00
2018-02-23 14:29:59 +00:00
2019-06-17 12:29:16 +02:00
2019-06-25 18:35:34 -03:00
2019-06-25 08:47:10 -03:00