Skip to content

Commit b570493

Browse files
authored
[SYCL] Added assertions to prevent null pointer dereferences (#14908)
This was pointed out by Coverity: it would seem that some functions are missing assertions to prevent dereferencing null pointers.
1 parent c79bbe8 commit b570493

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

sycl/source/detail/memory_manager.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,8 @@ static void memcpyFromDeviceGlobalUSM(
11571157
size_t NumBytes, size_t Offset, void *Dest,
11581158
const std::vector<ur_event_handle_t> &DepEvents,
11591159
ur_event_handle_t *OutEvent, const detail::EventImplPtr &OutEventImpl) {
1160+
assert(Queue && "Copying from device global USM must be called with a valid "
1161+
"device queue");
11601162
// Get or allocate USM memory for the device_global. Since we are reading from
11611163
// it, we need it initialized if it has not been yet.
11621164
DeviceGlobalUSMMem &DeviceGlobalUSM =

sycl/source/detail/scheduler/commands.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3233,6 +3233,7 @@ ur_result_t ExecCGCommand::enqueueImpQueue() {
32333233
return UR_RESULT_SUCCESS;
32343234
}
32353235
case CGType::ProfilingTag: {
3236+
assert(MQueue && "Profiling tag requires a valid queue");
32363237
const auto &Plugin = MQueue->getPlugin();
32373238
// If the queue is not in-order, we need to insert a barrier. This barrier
32383239
// does not need output events as it will implicitly enforce the following

0 commit comments

Comments
 (0)