OSDN Git Service

intel/aubinator: Free section data last
authorJason Ekstrand <jason.ekstrand@intel.com>
Wed, 27 Dec 2017 16:39:10 +0000 (08:39 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Thu, 28 Dec 2017 18:39:04 +0000 (10:39 -0800)
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@intel.com>
src/intel/tools/aubinator_error_decode.c

index d6fbfe0..9dd7079 100644 (file)
@@ -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