SWDEV-568847 - prevent UAF when registering callbacks on completed events (#2066)

* SWDEV-568847 - prevent UAF when registering callbacks on completed events

* cache the status() of event earlier

* Update command.cpp

* revert cl_event.cpp

* Update cl_event.cpp

---------

Co-authored-by: cadolphe-amd <chris.adolphe@amd.com>
This commit is contained in:
Victor Zhang
2025-12-09 11:38:45 -05:00
gecommit door GitHub
bovenliggende eea93d58a2
commit aaecffa50b
@@ -377,11 +377,17 @@ RUNTIME_ENTRY(cl_int, clSetEventCallback,
return CL_INVALID_VALUE;
}
if (!as_amd(event)->setCallback(command_exec_callback_type, pfn_notify, user_data)) {
amd::Event* ev = as_amd(event);
ev->retain();
if (!ev->setCallback(command_exec_callback_type, pfn_notify, user_data)) {
ev->release();
return CL_OUT_OF_HOST_MEMORY;
}
as_amd(event)->notifyCmdQueue();
if (ev->status() > CL_COMPLETE) {
ev->notifyCmdQueue();
}
ev->release();
return CL_SUCCESS;
}