aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace_kprobe.c
diff options
context:
space:
mode:
authorMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>2010-08-27 07:38:46 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2010-09-08 10:47:18 -0400
commit61a527362234ac3352a91ac67c50c6f7cd248eb1 (patch)
tree6d3ed6390f61d7819c11b459d86d5dac76ca7f0c /kernel/trace/trace_kprobe.c
parent9c55cb12c1c172e2d51e85fbb5a4796ca86b77e7 (diff)
tracing/kprobe: Fix a memory leak in error case
Fix a memory leak which happens when a field name conflicts with others. In error case, free_trace_probe() will free all arguments until nr_args, so this increments nr_args the begining of the loop instead of the end. Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> LKML-Reference: <20100827113846.22882.12670.stgit@ltc236.sdl.hitachi.co.jp> Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'kernel/trace/trace_kprobe.c')
-rw-r--r--kernel/trace/trace_kprobe.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index 8b27c9849b42..0116c038b0bc 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -992,6 +992,9 @@ static int create_trace_probe(int argc, char **argv)
992 /* parse arguments */ 992 /* parse arguments */
993 ret = 0; 993 ret = 0;
994 for (i = 0; i < argc && i < MAX_TRACE_ARGS; i++) { 994 for (i = 0; i < argc && i < MAX_TRACE_ARGS; i++) {
995 /* Increment count for freeing args in error case */
996 tp->nr_args++;
997
995 /* Parse argument name */ 998 /* Parse argument name */
996 arg = strchr(argv[i], '='); 999 arg = strchr(argv[i], '=');
997 if (arg) 1000 if (arg)
@@ -1021,11 +1024,8 @@ static int create_trace_probe(int argc, char **argv)
1021 ret = parse_probe_arg(arg, tp, &tp->args[i], is_return); 1024 ret = parse_probe_arg(arg, tp, &tp->args[i], is_return);
1022 if (ret) { 1025 if (ret) {
1023 pr_info("Parse error at argument%d. (%d)\n", i, ret); 1026 pr_info("Parse error at argument%d. (%d)\n", i, ret);
1024 kfree(tp->args[i].name);
1025 goto error; 1027 goto error;
1026 } 1028 }
1027
1028 tp->nr_args++;
1029 } 1029 }
1030 1030
1031 ret = register_trace_probe(tp); 1031 ret = register_trace_probe(tp);