Skip to content

[OpenCL] Fix memory leak and coverity issue with struct-to-array casts#1048

Merged
kbenzie merged 2 commits intooneapi-src:adaptersfrom
callumfare:opencl_fix_urMemBufferCreate_leak
Nov 20, 2023
Merged

[OpenCL] Fix memory leak and coverity issue with struct-to-array casts#1048
kbenzie merged 2 commits intooneapi-src:adaptersfrom
callumfare:opencl_fix_urMemBufferCreate_leak

Conversation

@callumfare
Copy link
Contributor

@callumfare callumfare commented Nov 7, 2023

Fix memory leak reported in #1034

This bug was introduced when porting the original OpenCL plugin to UR. If the clCreateBufferWithProperties extension function exists, we should return even if it succeeds rather than continuing to the fallback call to clCreateBuffer.

Also add fixes from #1054:

Address coverity issue with dodgy struct-to-array casts

Also fix a similar issue coverity had with CreateProgramWithBinary which was passing array pointers straight through to the cl entry point by putting these params in local const arrays.

@callumfare callumfare requested a review from a team as a code owner November 7, 2023 16:13
@callumfare
Copy link
Contributor Author

LLVM PR for testing: intel/llvm#11806

@callumfare callumfare force-pushed the opencl_fix_urMemBufferCreate_leak branch 2 times, most recently from 75e0679 to 2ed872d Compare November 10, 2023 12:10
@callumfare callumfare force-pushed the opencl_fix_urMemBufferCreate_leak branch from 2ed872d to 46cf37f Compare November 14, 2023 14:06
Also fix a similar issue coverity had with CreateProgramWithBinary which
was passing array pointers straight through to the cl entry point by
putting these params in local const arrays.
@callumfare callumfare changed the title [OpenCL] Fix memory leak by avoiding duplicate calls in urMemBufferCreate [OpenCL] Fix memory leak and coverity issue with struct-to-array casts Nov 15, 2023
@kbenzie kbenzie merged commit 04799e7 into oneapi-src:adapters Nov 20, 2023
steffenlarsen pushed a commit to intel/llvm that referenced this pull request Nov 21, 2023
Includes UR changes from [ [OpenCL] Fix memory leak and coverity issue
with struct-to-array casts #1048
](oneapi-src/unified-runtime#1048).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants