public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC] perf: Prevent potential null dereference
@ 2010-12-02 22:26 Cyrill Gorcunov
  2010-12-02 22:41 ` Frederic Weisbecker
  0 siblings, 1 reply; 7+ messages in thread
From: Cyrill Gorcunov @ 2010-12-02 22:26 UTC (permalink / raw)
  To: LKML
  Cc: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
	Frederic Weisbecker

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++) {

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-12-06 14:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-02 22:26 [RFC] perf: Prevent potential null dereference Cyrill Gorcunov
2010-12-02 22:41 ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox