From: Jiri Olsa <jolsa@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org,
Masanari Iida <standby24x7@gmail.com>,
Jiri Olsa <jolsa@kernel.org>
Subject: [PATCH 4/8] perf session: Fix possible null pointer dereference in session.c
Date: Mon, 19 May 2014 14:30:52 +0200 [thread overview]
Message-ID: <1400502656-20751-5-git-send-email-jolsa@kernel.org> (raw)
In-Reply-To: <1400502656-20751-1-git-send-email-jolsa@kernel.org>
From: Masanari Iida <standby24x7@gmail.com>
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>
---
tools/perf/util/session.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 55960f2..64a186e 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1625,13 +1625,14 @@ out_delete_map:
void perf_session__fprintf_info(struct perf_session *session, FILE *fp,
bool full)
{
- int fd = perf_data_file__fd(session->file);
struct stat st;
- int ret;
+ int fd, ret;
if (session == NULL || fp == NULL)
return;
+ fd = perf_data_file__fd(session->file);
+
ret = fstat(fd, &st);
if (ret == -1)
return;
--
1.8.3.1
next prev parent reply other threads:[~2014-05-19 12:31 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-19 12:30 [GIT PULL 0/8] perf/core improvements and fixes Jiri Olsa
2014-05-19 12:30 ` [PATCH 1/8] perf tools: Remove usage of trace_sched_wakeup(.success) Jiri Olsa
2014-05-19 12:30 ` [PATCH 2/8] perf sched: Remove nr_state_machine_bugs in perf latency Jiri Olsa
2014-05-19 12:30 ` [PATCH 3/8] perf sched: Cleanup, remove unused variables in map_switch_event() Jiri Olsa
2014-05-19 12:30 ` Jiri Olsa [this message]
2014-05-19 12:30 ` [PATCH 5/8] perf tools: Consolidate types.h for ARM and ARM64 Jiri Olsa
2014-05-19 12:30 ` [PATCH 6/8] perf tests: Introduce perf_regs_load function on ARM Jiri Olsa
2014-05-19 12:30 ` [PATCH 7/8] perf tests: Add dwarf unwind test " Jiri Olsa
2014-05-19 12:30 ` [PATCH 8/8] perf tools: Add libdw DWARF post unwind support for ARM Jiri Olsa
2014-05-20 6:37 ` [GIT PULL 0/8] perf/core improvements and 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=1400502656-20751-5-git-send-email-jolsa@kernel.org \
--to=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=standby24x7@gmail.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.