[Mesa-dev] [PATCH v2 3/4] intel: tools: aubwrite: fix invalid frees on finish

Jordan Justen jordan.l.justen at intel.com
Thu Jul 19 19:03:42 UTC 2018


Reviewed-by: Jordan Justen <jordan.l.justen at intel.com>

On 2018-07-18 10:21:31, Lionel Landwerlin wrote:
> Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
> ---
>  src/intel/tools/aub_write.c | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/src/intel/tools/aub_write.c b/src/intel/tools/aub_write.c
> index 1224e8f6b7f..de00004ce33 100644
> --- a/src/intel/tools/aub_write.c
> +++ b/src/intel/tools/aub_write.c
> @@ -255,11 +255,16 @@ align_u32(uint32_t v, uint32_t a)
>  }
>  
>  static void
> -aub_ppgtt_table_finish(struct aub_ppgtt_table *table)
> +aub_ppgtt_table_finish(struct aub_ppgtt_table *table, int level)
>  {
> +   if (level == 1)
> +      return;
> +
>     for (unsigned i = 0; i < ARRAY_SIZE(table->subtables); i++) {
> -      aub_ppgtt_table_finish(table->subtables[i]);
> -      free(table->subtables[i]);
> +      if (table->subtables[i]) {
> +         aub_ppgtt_table_finish(table->subtables[i], level - 1);
> +         free(table->subtables[i]);
> +      }
>     }
>  }
>  
> @@ -280,7 +285,7 @@ aub_file_init(struct aub_file *aub, FILE *file, uint16_t pci_id)
>  void
>  aub_file_finish(struct aub_file *aub)
>  {
> -   aub_ppgtt_table_finish(&aub->pml4);
> +   aub_ppgtt_table_finish(&aub->pml4, 4);
>     fclose(aub->file);
>  }
>  
> -- 
> 2.18.0
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list