aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorMasanari Iida <standby24x7@gmail.com>2014-05-14 13:13:38 -0400
committerJiri Olsa <jolsa@kernel.org>2014-05-16 03:18:51 -0400
commitc5765ece8a050836c6255e1276fc8e0e867078da (patch)
treec2cfc515ddacd64fa9be9d1a0ebe8b10596a9ccb /tools/perf
parent9d372ca59bcb9339b4a34a9bf978a1fc15b68b03 (diff)
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: Masanari Iida <standby24x7@gmail.com> Link: http://lkml.kernel.org/r/1400087618-13628-1-git-send-email-standby24x7@gmail.com Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/util/session.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 55960f22233c..64a186edc7be 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1625,13 +1625,14 @@ out_delete_map:
1625void perf_session__fprintf_info(struct perf_session *session, FILE *fp, 1625void perf_session__fprintf_info(struct perf_session *session, FILE *fp,
1626 bool full) 1626 bool full)
1627{ 1627{
1628 int fd = perf_data_file__fd(session->file);
1629 struct stat st; 1628 struct stat st;
1630 int ret; 1629 int fd, ret;
1631 1630
1632 if (session == NULL || fp == NULL) 1631 if (session == NULL || fp == NULL)
1633 return; 1632 return;
1634 1633
1634 fd = perf_data_file__fd(session->file);
1635
1635 ret = fstat(fd, &st); 1636 ret = fstat(fd, &st);
1636 if (ret == -1) 1637 if (ret == -1)
1637 return; 1638 return;