From ab60a07e1de501d8681ebc0835ac63677edfb7f2 Mon Sep 17 00:00:00 2001 From: Yiannis Papadopoulos <102817138+ypapadop-amd@users.noreply.github.com> Date: Wed, 4 Sep 2024 09:44:05 -0400 Subject: [PATCH] Releasing buffer for XDNA hw context params (#18) --- runtime/hsa-runtime/core/driver/xdna/amd_xdna_driver.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/runtime/hsa-runtime/core/driver/xdna/amd_xdna_driver.cpp b/runtime/hsa-runtime/core/driver/xdna/amd_xdna_driver.cpp index d21fdbc5f..4982bc910 100644 --- a/runtime/hsa-runtime/core/driver/xdna/amd_xdna_driver.cpp +++ b/runtime/hsa-runtime/core/driver/xdna/amd_xdna_driver.cpp @@ -393,6 +393,11 @@ hsa_status_t XdnaDriver::ConfigHwCtxCU( amdxdna_hwctx_param_config_cu *xdna_config_cu_param = reinterpret_cast( malloc(config_cu_param_size)); + if (xdna_config_cu_param == nullptr) { + return HSA_STATUS_ERROR_OUT_OF_RESOURCES; + } + MAKE_SCOPE_GUARD([xdna_config_cu_param] { free(xdna_config_cu_param); }); + xdna_config_cu_param->num_cus = config_cu_param.num_cus; for (int i = 0; i < xdna_config_cu_param->num_cus; ++i) {