From: Julia Lawall Date: Sun, 6 Dec 2009 09:16:30 +0000 (+0100) Subject: perf tools: Correct size computation in tracepoint_id_to_path() X-Git-Tag: v2.6.33-rc1~48^2~113 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=59b4caeb797494043f5f3b98a610f5d9b75eefa3;p=linux-2.6-block.git perf tools: Correct size computation in tracepoint_id_to_path() The size argument to zalloc should be the size of desired structure, not the pointer to it. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @expression@ expression *x; @@ x = <+... -sizeof(x) +sizeof(*x) ...+>// Signed-off-by: Julia Lawall Cc: Peter Zijlstra Cc: Mike Galbraith Cc: Paul Mackerras Cc: Arnaldo Carvalho de Melo Cc: Frederic Weisbecker LKML-Reference: Signed-off-by: Ingo Molnar --- diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 9e5dbd66d34d..448a13b52015 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -197,7 +197,7 @@ struct tracepoint_path *tracepoint_id_to_path(u64 config) if (id == config) { closedir(evt_dir); closedir(sys_dir); - path = zalloc(sizeof(path)); + path = zalloc(sizeof(*path)); path->system = malloc(MAX_EVENT_LENGTH); if (!path->system) { free(path);