From 6fcb2c655ff582aaa638d75e6bb59adeea812f4b Mon Sep 17 00:00:00 2001 From: Vladana Stojiljkovic Date: Thu, 25 Jul 2024 17:00:29 +0200 Subject: [PATCH] SWDEV-475127 - Check if hipBindTextureToArray parameters are null before dereferencing them Change-Id: Id0173faff0a385d1665194c9033083ef9b2c48b5 [ROCm/clr commit: d7b07b94a021960ebc37af6d576dd0e9145ca32d] --- projects/clr/hipamd/src/hip_texture.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/projects/clr/hipamd/src/hip_texture.cpp b/projects/clr/hipamd/src/hip_texture.cpp index 57ecfe3848..21cccda234 100644 --- a/projects/clr/hipamd/src/hip_texture.cpp +++ b/projects/clr/hipamd/src/hip_texture.cpp @@ -633,12 +633,6 @@ hipError_t hipBindTexture2D(size_t* offset, hipError_t ihipBindTextureToArray(const textureReference* texref, hipArray_const_t array, const hipChannelFormatDesc* desc) { - if ((texref == nullptr) || - (array == nullptr) || - (desc == nullptr)) { - return hipErrorInvalidValue; - } - // Any previous address or HIP array state associated with the texture reference is superseded by this function. // Any memory previously bound to hTexRef is unbound. // No need to check for errors. @@ -664,6 +658,10 @@ hipError_t hipBindTextureToArray(const textureReference* texref, const hipChannelFormatDesc* desc) { HIP_INIT_API(hipBindTextureToArray, texref, array, desc); + if ((texref == nullptr) || (array == nullptr) || (desc == nullptr)) { + return hipErrorInvalidValue; + } + hipDeviceptr_t refDevPtr = nullptr; size_t refDevSize = 0; HIP_RETURN_ONFAIL(PlatformState::instance().getStatGlobalVar(texref, ihipGetDevice(), &refDevPtr,