Re: [PATCH] trace-input: init kbuf back to NULL after free kbuf

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 28 Feb 2014 13:50:42 +0800
Ditang Chen <chendt.fnst@xxxxxxxxxxxxxx> wrote:

> Reads a wrong trace.dat file, the read_cpu_data() function returns a 
> failure, it will cause memory double free. we should init kbuf back to
> NULL after free kbuf.

Thanks, I applied it and I'm currently testing it.

Just a note. This patch has severe whitespace issues (tabs converted to
spaces). But because it was small, I was able to cope.

-- Steve

> 
> Signed-off-by: Ditang Chen <chendt.fnst@xxxxxxxxxxxxxx>
> ---
>  trace-input.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/trace-input.c b/trace-input.c
> index 6eef168..b91ea50 100644
> --- a/trace-input.c
> +++ b/trace-input.c
> @@ -1870,6 +1870,7 @@ static int read_cpu_data(struct tracecmd_input *handle)
>         for ( ; cpu >= 0; cpu--) {
>                 free_page(handle, cpu);
>                 kbuffer_free(handle->cpu_data[cpu].kbuf);
> +               handle->cpu_data[cpu].kbuf = NULL;
>         }
>         return -1;
> 
> @@ -2209,7 +2210,7 @@ void tracecmd_close(struct tracecmd_input *handle)
>                 /* The tracecmd_peek_data may have cached a record */
>                 free_next(handle, cpu);
>                 free_page(handle, cpu);
> -               if (handle->cpu_data) {
> +               if (handle->cpu_data && handle->cpu_data[cpu].kbuf) {
>                         kbuffer_free(handle->cpu_data[cpu].kbuf);
> 
>                         if (!list_empty(&handle->cpu_data[cpu].pages))

--
To unsubscribe from this list: send the line "unsubscribe linux-trace-users" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux