Skip to content

Commit e2e5769

Browse files
committed
Double check the dditable is checked even if the driver reports the api version
Signed-off-by: Neil R. Spruit <neil.r.spruit@intel.com>
1 parent 41e5e32 commit e2e5769

6 files changed

Lines changed: 1670 additions & 2 deletions

File tree

scripts/templates/ldrddi_driver_ddi.cpp.mako

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ namespace loader_driver_ddi
6565
if (dditable->version < ${th.get_version(obj)}) {
6666
return ${X}_RESULT_ERROR_UNSUPPORTED_VERSION;
6767
}
68+
// Check that the driver has the function pointer table init
69+
if (dditable->${th.get_table_name(n, tags, obj)} == nullptr) {
70+
return ${X}_RESULT_ERROR_UNSUPPORTED_VERSION;
71+
}
6872
auto ${th.make_pfn_name(n, tags, obj)} = dditable->${th.get_table_name(n, tags, obj)}->${th.make_pfn_name(n, tags, obj)};
6973
if( nullptr == ${th.make_pfn_name(n, tags, obj)} )
7074
return ${X}_RESULT_ERROR_UNINITIALIZED;

scripts/templates/libapi.cpp.mako

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ ${th.make_func_name(n, tags, obj)}(
166166
return ${X}_RESULT_ERROR_UNINITIALIZED;
167167
}
168168
%if re.match(r"\w+DriverGet$", th.make_func_name(n, tags, obj)):
169-
if (${x}_lib::context->${n}DdiTable == nullptr) {
169+
if (!${x}_lib::context || ${x}_lib::context->${n}DdiTable == nullptr) {
170170
return ${X}_RESULT_ERROR_UNINITIALIZED;
171171
}
172172
%endif

source/lib/zes_libapi.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ zesDriverGet(
115115
if(ze_lib::destruction) {
116116
return ZE_RESULT_ERROR_UNINITIALIZED;
117117
}
118-
if (ze_lib::context->zesDdiTable == nullptr) {
118+
if (!ze_lib::context || ze_lib::context->zesDdiTable == nullptr) {
119119
return ZE_RESULT_ERROR_UNINITIALIZED;
120120
}
121121
static const zes_pfnDriverGet_t pfnGet = [&result] {

0 commit comments

Comments
 (0)