Mesa (master): intel/aubinator: Free section data last

Jason Ekstrand jekstrand at kemper.freedesktop.org
Thu Dec 28 18:33:43 UTC 2017


Module: Mesa
Branch: master
Commit: 5b865d7ada03bd94ee7e1445ca33adc14e46646c
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=5b865d7ada03bd94ee7e1445ca33adc14e46646c

Author: Jason Ekstrand <jason.ekstrand at intel.com>
Date:   Wed Dec 27 08:39:10 2017 -0800

intel/aubinator: Free section data last

We were walking the sections, printing the batches, and then freeing
them in one pass.  If the batch happens to reference any earlier
sections (which it almost certainly will since it's at the end), we will
access freed memory.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>

---

 src/intel/tools/aubinator_error_decode.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/intel/tools/aubinator_error_decode.c b/src/intel/tools/aubinator_error_decode.c
index d6fbfe0eb8..9dd70790e1 100644
--- a/src/intel/tools/aubinator_error_decode.c
+++ b/src/intel/tools/aubinator_error_decode.c
@@ -521,12 +521,14 @@ read_data_file(FILE *file)
          gen_print_batch(&batch_ctx, sections[s].data, sections[s].count,
                          sections[s].gtt_offset);
       }
+   }
+
+   gen_batch_decode_ctx_finish(&batch_ctx);
 
+   for (int s = 0; s < sect_num; s++) {
       free(sections[s].ring_name);
       free(sections[s].data);
    }
-
-   gen_batch_decode_ctx_finish(&batch_ctx);
 }
 
 static void




More information about the mesa-commit mailing list