intel/tools: Improve memory allocation failure handling in aubinator_error_decode_xe

Ensure proper cleanup when memory allocation fails during HWCTX and VMA
parsing in `read_xe_data_file`. This ensures graceful error handling by
preventing potential memory leaks.

Reviewed-by: José Roberto de Souza <jose.souza@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34371>
This commit is contained in:
Sushma Venkatesh Reddy
2025-04-03 19:05:23 +00:00
committed by Marge Bot
parent 9ddc160012
commit 8f90b10b63
+6 -2
View File
@@ -247,7 +247,8 @@ read_xe_data_file(FILE *file,
vm_entry_data = calloc(1, vm_entry_len);
if (!vm_entry_data) {
printf("Out of memory to allocate a buffer to store content of HWCTX\n");
break;
printf("Aborting decode process due to insufficient memory\n");
goto cleanup;
}
if (is_hw_ctx)
@@ -282,7 +283,8 @@ read_xe_data_file(FILE *file,
vm_entry_data = calloc(1, vm_entry_len);
if (!vm_entry_data) {
printf("Out of memory to allocate a buffer to store content of VMA 0x%" PRIx64 "\n", address);
break;
printf("Aborting decode process due to insufficient memory\n");
goto cleanup;
}
if (!error_decode_xe_vm_append(&xe_vm, address, vm_entry_len, vm_entry_data)) {
printf("xe_vm_append() failed for VMA 0x%" PRIx64 "\n", address);
@@ -349,6 +351,8 @@ read_xe_data_file(FILE *file,
}
intel_batch_decode_ctx_finish(&batch_ctx);
cleanup:
intel_spec_destroy(spec);
free(batch_buffers.addrs);
free(line);