[RFC][PATCH 03/11] ftrace: fix memory leak

From: Peter Zijlstra
Date: Tue Mar 17 2009 - 18:07:44 EST


Don't return after an allocation without freeing -- fix it by moving the check
up a few lines.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
---
kernel/trace/trace_events.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

Index: linux-2.6/kernel/trace/trace_events.c
===================================================================
--- linux-2.6.orig/kernel/trace/trace_events.c
+++ linux-2.6/kernel/trace/trace_events.c
@@ -380,15 +380,15 @@ event_format_read(struct file *filp, cha
char *buf;
int r;

+ if (*ppos)
+ return 0;
+
s = kmalloc(sizeof(*s), GFP_KERNEL);
if (!s)
return -ENOMEM;

trace_seq_init(s);

- if (*ppos)
- return 0;
-
/* If any of the first writes fail, so will the show_format. */

trace_seq_printf(s, "name: %s\n", call->name);

--

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/