diff options
author | Steven Rostedt <srostedt@redhat.com> | 2011-04-18 18:05:37 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2011-04-18 18:07:26 -0400 |
commit | d064f23c81abfa662a6d55711b6b8ffb3d756978 (patch) | |
tree | 3f7224e115f76cc09f95c4f0c8a94d2e55efb49f | |
parent | 596e9a8a69ef2ca04da55d46d6a7569e54962ebb (diff) |
trace-graph: Fix saved pointer corruption in update_last_record()
The saved pointer was created with tracecmd_peek_data() and then set_cpu_to_time()
was called freeing the saved pointer. We could simply reference the pointer if
need be, but using tracecmd_read_data() is a better solution.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r-- | trace-plot-task.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/trace-plot-task.c b/trace-plot-task.c index 552f274..9ca97a3 100644 --- a/trace-plot-task.c +++ b/trace-plot-task.c | |||
@@ -376,20 +376,23 @@ static void update_last_record(struct graph_info *ginfo, | |||
376 | } else { | 376 | } else { |
377 | static int once; | 377 | static int once; |
378 | 378 | ||
379 | saved = tracecmd_peek_data(handle, cpu); | 379 | saved = tracecmd_read_data(handle, cpu); |
380 | set_cpu_to_time(cpu, ginfo, ts); | 380 | set_cpu_to_time(cpu, ginfo, ts); |
381 | t2record = tracecmd_read_data(handle, cpu); | 381 | t2record = tracecmd_read_data(handle, cpu); |
382 | trecord = tracecmd_read_prev(handle, t2record); | 382 | trecord = tracecmd_read_prev(handle, t2record); |
383 | free_record(t2record); | 383 | free_record(t2record); |
384 | /* reset cursor back to what it was */ | 384 | /* reset cursor back to what it was */ |
385 | if (saved) | 385 | if (saved) { |
386 | tracecmd_set_cursor(handle, cpu, saved->offset); | 386 | tracecmd_set_cursor(handle, cpu, saved->offset); |
387 | else { | 387 | free_record(saved); |
388 | } else { | ||
388 | saved = tracecmd_read_data(handle, cpu); | 389 | saved = tracecmd_read_data(handle, cpu); |
389 | if (!once && saved) { | 390 | if (!once && saved) { |
390 | once++; | 391 | once++; |
391 | warning("failed to reset cursor to end!"); | 392 | warning("failed to reset cursor to end!"); |
392 | } | 393 | } |
394 | /* saved should always be NULL */ | ||
395 | free_record(saved); | ||
393 | } | 396 | } |
394 | } | 397 | } |
395 | if (!trecord) | 398 | if (!trecord) |