lkml.org 
[lkml]   [2010]   [Dec]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[RFC] perf: Prevent potential null dereference
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++) {

\
 
 \ /
  Last update: 2010-12-02 23:29    [W:0.925 / U:0.068 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site