Skip to content

Commit 0c541bd

Browse files
[SYCL][L0] Fix 'resource leak' type of Coverity issues (#7192)
Signed-off-by: Sergey V Maslov <sergey.v.maslov@intel.com>
1 parent 97c0c99 commit 0c541bd

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

sycl/plugins/level_zero/pi_level_zero.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2311,12 +2311,13 @@ pi_result piPlatformsGet(pi_uint32 NumEntries, pi_platform *Platforms,
23112311
ZE_CALL(zeDriverGet, (&ZeDriverCount, ZeDrivers.data()));
23122312
for (uint32_t I = 0; I < ZeDriverCount; ++I) {
23132313
pi_platform Platform = new _pi_platform(ZeDrivers[I]);
2314+
// Save a copy in the cache for future uses.
2315+
PiPlatformsCache->push_back(Platform);
2316+
23142317
pi_result Result = Platform->initialize();
23152318
if (Result != PI_SUCCESS) {
23162319
return Result;
23172320
}
2318-
// Save a copy in the cache for future uses.
2319-
PiPlatformsCache->push_back(Platform);
23202321
}
23212322
PiPlatformCachePopulated = true;
23222323
}
@@ -4221,6 +4222,7 @@ pi_result piMemImageCreate(pi_context Context, pi_mem_flags Flags,
42214222

42224223
try {
42234224
auto ZePIImage = new _pi_image(Context, ZeHImage);
4225+
*RetImage = ZePIImage;
42244226

42254227
#ifndef NDEBUG
42264228
ZePIImage->ZeImageDesc = ZeImageDesc;
@@ -4237,8 +4239,6 @@ pi_result piMemImageCreate(pi_context Context, pi_mem_flags Flags,
42374239
(Context->ZeCommandListInit, ZeHImage, HostPtr, nullptr, nullptr,
42384240
0, nullptr));
42394241
}
4240-
4241-
*RetImage = ZePIImage;
42424242
} catch (const std::bad_alloc &) {
42434243
return PI_ERROR_OUT_OF_HOST_MEMORY;
42444244
} catch (...) {

0 commit comments

Comments
 (0)