lkml.org 
[lkml]   [2016]   [Oct]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] tools lib traceevent: Fix kbuffer_read_at_offset()
On Sat,  1 Oct 2016 19:17:00 +0900
Namhyung Kim <namhyung@kernel.org> wrote:

> When it's called with an offset less than or equal to the first event,
> it'll return a garbage value since the data is not initialized.

Well, it can at most be equal to (unless offset is negative) because
kbuffer_load_subbuffer() sets kbuf->curr to zero.

But that said, it looks like offset == 0 is buggy.

Acked-by: Steven Rostedt <rostedt@goodmis.org>


-- Steve

>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
> tools/lib/traceevent/kbuffer-parse.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/tools/lib/traceevent/kbuffer-parse.c b/tools/lib/traceevent/kbuffer-parse.c
> index 3bcada3ae05a..65984f1c2974 100644
> --- a/tools/lib/traceevent/kbuffer-parse.c
> +++ b/tools/lib/traceevent/kbuffer-parse.c
> @@ -622,6 +622,7 @@ void *kbuffer_read_at_offset(struct kbuffer *kbuf, int offset,
>
> /* Reset the buffer */
> kbuffer_load_subbuffer(kbuf, kbuf->subbuffer);
> + data = kbuffer_read_event(kbuf, ts);
>
> while (kbuf->curr < offset) {
> data = kbuffer_next_event(kbuf, ts);

\
 
 \ /
  Last update: 2016-10-05 15:29    [W:0.125 / U:0.132 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site