Commit c5765ece authored by Masanari Iida's avatar Masanari Iida Committed by Jiri Olsa

perf session: Fix possible null pointer dereference in session.c

cppcheck detected following warning:
[tools/perf/util/session.c:1628] -> [tools/perf/util/session.c:1632]:
 (warning) Possible null pointer dereference: session - otherwise it
 is redundant to check it against null.

In order to avoide null pointer, check the pointer before use.
Signed-off-by: default avatarMasanari Iida <standby24x7@gmail.com>
Link: http://lkml.kernel.org/r/1400087618-13628-1-git-send-email-standby24x7@gmail.comSigned-off-by: default avatarJiri Olsa <jolsa@kernel.org>
parent 9d372ca5
...@@ -1625,13 +1625,14 @@ int perf_session__cpu_bitmap(struct perf_session *session, ...@@ -1625,13 +1625,14 @@ int perf_session__cpu_bitmap(struct perf_session *session,
void perf_session__fprintf_info(struct perf_session *session, FILE *fp, void perf_session__fprintf_info(struct perf_session *session, FILE *fp,
bool full) bool full)
{ {
int fd = perf_data_file__fd(session->file);
struct stat st; struct stat st;
int ret; int fd, ret;
if (session == NULL || fp == NULL) if (session == NULL || fp == NULL)
return; return;
fd = perf_data_file__fd(session->file);
ret = fstat(fd, &st); ret = fstat(fd, &st);
if (ret == -1) if (ret == -1)
return; return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment