From: Jiri Olsa <jolsa@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: lkml <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
David Ahern <dsahern@gmail.com>, Andi Kleen <ak@linux.intel.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Peter Zijlstra <a.p.zijlstra@chello.nl>
Subject: [PATCH 1/2] tools lib symbol: Use strtoul instead of hex2u64 in kallsyms__parse
Date: Fri, 19 Jan 2018 17:11:02 +0100 [thread overview]
Message-ID: <20180119161103.15035-2-jolsa@kernel.org> (raw)
In-Reply-To: <20180119161103.15035-1-jolsa@kernel.org>
Current kallsyms__parse uses hex2u64, which gives
no indication of error. Using strtoul to checkup
on failed attempt to parse the number and stop the
rest of the kallsyms__parse processing early.
Link: http://lkml.kernel.org/n/tip-djqwni3p6lgctf6o7xhhwpmw@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/lib/symbol/kallsyms.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/tools/lib/symbol/kallsyms.c b/tools/lib/symbol/kallsyms.c
index 914cb8e3d40b..dd5bb1dfd2b6 100644
--- a/tools/lib/symbol/kallsyms.c
+++ b/tools/lib/symbol/kallsyms.c
@@ -29,6 +29,7 @@ int kallsyms__parse(const char *filename, void *arg,
int line_len, len;
char symbol_type;
char *symbol_name;
+ char *endptr;
line_len = getline(&line, &n, file);
if (line_len < 0 || !line)
@@ -36,9 +37,12 @@ int kallsyms__parse(const char *filename, void *arg,
line[--line_len] = '\0'; /* \n */
- len = hex2u64(line, &start);
+ start = strtoul(line, &endptr, 16);
+ if (line == endptr)
+ continue;
+
+ len = endptr - line + 1;
- len++;
if (len + 2 >= line_len)
continue;
--
2.13.6
next prev parent reply other threads:[~2018-01-19 16:11 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-19 16:11 [PATCH 0/2] perf report: Fix kallsyms parsing Jiri Olsa
2018-01-19 16:11 ` Jiri Olsa [this message]
2018-01-26 6:36 ` [PATCH 1/2] tools lib symbol: Use strtoul instead of hex2u64 in kallsyms__parse Namhyung Kim
2018-01-26 17:22 ` Andy Shevchenko
2018-01-26 17:27 ` Andy Shevchenko
2018-01-29 7:18 ` Jiri Olsa
2018-01-29 13:05 ` Andy Shevchenko
2018-01-19 16:11 ` [PATCH 2/2] perf tools: Skip read of kernel maps once it failed Jiri Olsa
2018-01-26 6:48 ` Namhyung Kim
2018-01-30 11:21 ` Jiri Olsa
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=20180119161103.15035-2-jolsa@kernel.org \
--to=jolsa@kernel.org \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=dsahern@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).