[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20101202224104.GA1639@nowhere>
Date: Thu, 2 Dec 2010 23:41:08 +0100
From: Frederic Weisbecker <fweisbec@...il.com>
To: Cyrill Gorcunov <gorcunov@...il.com>
Cc: LKML <linux-kernel@...r.kernel.org>,
Arnaldo Carvalho de Melo <acme@...hat.com>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...e.hu>
Subject: Re: [RFC] perf: Prevent potential null dereference
On Fri, Dec 03, 2010 at 01:26:05AM +0300, Cyrill Gorcunov wrote:
> In case if there is no memory we might hit null
> dereference on accessing calloc'ed data.
>
> Signed-off-by: Cyrill Gorcunov <gorcunov@...nvz.org>
> CC: Arnaldo Carvalho de Melo <acme@...hat.com>
> CC: Peter Zijlstra <peterz@...radead.org>
> CC: Ingo Molnar <mingo@...e.hu>
> CC: Frederic Weisbecker <fweisbec@...il.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++) {
Good.
As a nit, not that it matters that much because we are very close to the starting code
anyway, but it would be better to propagate the error to the callers.
Thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists