diff --git a/projects/hip/samples/0_Intro/module_api/defaultDriver.cpp b/projects/hip/samples/0_Intro/module_api/defaultDriver.cpp index ea36aabcf4..af8b413ac2 100644 --- a/projects/hip/samples/0_Intro/module_api/defaultDriver.cpp +++ b/projects/hip/samples/0_Intro/module_api/defaultDriver.cpp @@ -80,8 +80,8 @@ int main() { hipFree(Ad); hipFree(Bd); - delete A; - delete B; + delete[] A; + delete[] B; hipCtxDestroy(context); return 0; } diff --git a/projects/hip/samples/0_Intro/module_api/launchKernelHcc.cpp b/projects/hip/samples/0_Intro/module_api/launchKernelHcc.cpp index 38cf0d414c..90e569c5bc 100644 --- a/projects/hip/samples/0_Intro/module_api/launchKernelHcc.cpp +++ b/projects/hip/samples/0_Intro/module_api/launchKernelHcc.cpp @@ -107,8 +107,8 @@ int main() { hipFree(Ad); hipFree(Bd); - delete A; - delete B; + delete[] A; + delete[] B; hipCtxDestroy(context); return 0; } diff --git a/projects/hip/samples/0_Intro/module_api/runKernel.cpp b/projects/hip/samples/0_Intro/module_api/runKernel.cpp index a011b42666..1093b0dd54 100644 --- a/projects/hip/samples/0_Intro/module_api/runKernel.cpp +++ b/projects/hip/samples/0_Intro/module_api/runKernel.cpp @@ -99,8 +99,8 @@ int main() { hipFree(Ad); hipFree(Bd); - delete A; - delete B; + delete[] A; + delete[] B; hipCtxDestroy(context); return 0; } diff --git a/projects/hip/samples/0_Intro/module_api_global/runKernel.cpp b/projects/hip/samples/0_Intro/module_api_global/runKernel.cpp index 3a2804b7a2..4a2d49144c 100644 --- a/projects/hip/samples/0_Intro/module_api_global/runKernel.cpp +++ b/projects/hip/samples/0_Intro/module_api_global/runKernel.cpp @@ -154,8 +154,8 @@ int main() { hipFree(Ad); hipFree(Bd); - delete A; - delete B; + delete[] A; + delete[] B; hipCtxDestroy(context); return 0; } diff --git a/projects/hip/src/hip_module.cpp b/projects/hip/src/hip_module.cpp index 5334e3ff4d..116c4ff94c 100644 --- a/projects/hip/src/hip_module.cpp +++ b/projects/hip/src/hip_module.cpp @@ -330,22 +330,18 @@ hipError_t ihipExtLaunchMultiKernelMultiDevice(hipLaunchParams* launchParamsList return hipErrorInvalidValue; } - hipFunction_t* kds = reinterpret_cast(malloc(sizeof(hipFunction_t) * numDevices)); - if (kds == nullptr) { - return hipErrorNotInitialized; - } + std::vector kds(numDevices,0); // prepare all kernel descriptors for each device as all streams will be locked in the next loop for (int i = 0; i < numDevices; ++i) { const hipLaunchParams& lp = launchParamsList[i]; if (lp.stream == nullptr) { - free(kds); return hipErrorNotInitialized; } kds[i] = ps.kernel_descriptor(reinterpret_cast(lp.func), hip_impl::target_agent(lp.stream)); + if (kds[i] == nullptr) { - free(kds); return hipErrorInvalidValue; } hip_impl::kernargs_size_align kargs = ps.get_kernargs_size_align( @@ -398,8 +394,6 @@ hipError_t ihipExtLaunchMultiKernelMultiDevice(hipLaunchParams* launchParamsList #endif } - free(kds); - return result; } diff --git a/projects/hip/src/hip_texture.cpp b/projects/hip/src/hip_texture.cpp index 27cf321fbc..5d673ddc79 100644 --- a/projects/hip/src/hip_texture.cpp +++ b/projects/hip/src/hip_texture.cpp @@ -312,6 +312,7 @@ hipError_t hipCreateTextureObject(hipTextureObject_t* pTexObject, const hipResou HSA_EXT_IMAGE_DATA_LAYOUT_LINEAR, pitch, 0, &(pTexture->image)) || HSA_STATUS_SUCCESS != hsa_ext_sampler_create(*agent, &samplerDescriptor, &(pTexture->sampler))) { + free(pTexture); return ihipLogStatus(hipErrorRuntimeOther); } @@ -449,6 +450,7 @@ hipError_t ihipBindTextureImpl(TlsData *tls_, int dim, enum hipTextureReadMode r HSA_EXT_IMAGE_DATA_LAYOUT_LINEAR, rowPitch, 0, &(pTexture->image)) || HSA_STATUS_SUCCESS != hsa_ext_sampler_create(*agent, &samplerDescriptor, &(pTexture->sampler))) { + free(pTexture); return hipErrorRuntimeOther; } getHipTextureObject(&textureObject, pTexture->image, pTexture->sampler); @@ -525,6 +527,7 @@ hipError_t ihipBindTexture2DImpl(TlsData *tls, int dim, enum hipTextureReadMode HSA_EXT_IMAGE_DATA_LAYOUT_LINEAR, pitch, 0, &(pTexture->image)) || HSA_STATUS_SUCCESS != hsa_ext_sampler_create(*agent, &samplerDescriptor, &(pTexture->sampler))) { + free(pTexture); return hipErrorRuntimeOther; } getHipTextureObject(&textureObject, pTexture->image, pTexture->sampler); diff --git a/projects/hip/tests/src/runtimeApi/module/hipModuleLoadDataMultThreaded.cpp b/projects/hip/tests/src/runtimeApi/module/hipModuleLoadDataMultThreaded.cpp index e73bbedba5..6bbbbbef34 100644 --- a/projects/hip/tests/src/runtimeApi/module/hipModuleLoadDataMultThreaded.cpp +++ b/projects/hip/tests/src/runtimeApi/module/hipModuleLoadDataMultThreaded.cpp @@ -107,8 +107,8 @@ void run(const std::vector& buffer) { hipFree(Ad); hipFree(Bd); - delete A; - delete B; + delete[] A; + delete[] B; hipCtxDestroy(context); }