From: Cyrill Gorcunov <gorcunov@gmail.com>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@elte.hu>,
Frederic Weisbecker <fweisbec@gmail.com>
Subject: [RFC] perf: Prevent potential null dereference
Date: Fri, 3 Dec 2010 01:26:05 +0300 [thread overview]
Message-ID: <20101202222605.GA6471@lenovo> (raw)
In case if there is no memory we might hit null
dereference on accessing calloc'ed data.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
CC: Arnaldo Carvalho de Melo <acme@redhat.com>
CC: Peter Zijlstra <peterz@infradead.org>
CC: Ingo Molnar <mingo@elte.hu>
CC: Frederic Weisbecker <fweisbec@gmail.com>
---
It seems exit right here is more convenient than passing error
handling level up (which would have to exit anyway), thought
if handling it "upper" is preferred -- just say a word.
tools/perf/builtin-record.c | 4 ++++
1 file changed, 4 insertions(+)
Index: linux-2.6.git/tools/perf/builtin-record.c
=====================================================================
--- linux-2.6.git.orig/tools/perf/builtin-record.c
+++ linux-2.6.git/tools/perf/builtin-record.c
@@ -524,6 +524,10 @@ static void comm__construct(int argc, co
return;
comm = calloc(1, size);
+ if (!comm) {
+ pr_err("Not enough memory to construct internal command line.\n");
+ exit(-1);
+ }
tmp = comm;
for (i = 0; i < argc; i++) {
next reply other threads:[~2010-12-02 22:26 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-02 22:26 Cyrill Gorcunov [this message]
2010-12-02 22:41 ` [RFC] perf: Prevent potential null dereference Frederic Weisbecker
2010-12-02 22:46 ` Arnaldo Carvalho de Melo
2010-12-02 22:48 ` Cyrill Gorcunov
2010-12-05 22:13 ` Cyrill Gorcunov
2010-12-06 14:49 ` Arnaldo Carvalho de Melo
2010-12-06 14:59 ` Cyrill Gorcunov
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=20101202222605.GA6471@lenovo \
--to=gorcunov@gmail.com \
--cc=acme@redhat.com \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=peterz@infradead.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