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

From: Steven Rostedt
Date: Tue Mar 17 2009 - 18:49:42 EST



Tom Zanussi beat you to it ;-)

http://marc.info/?l=linux-kernel&m=123727898221734&w=2

-- Steve


On Tue, 17 Mar 2009, Peter Zijlstra wrote:

> 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/