From 98006ce72ae73b01c1e8dcf8b27a84d6d75e24c6 Mon Sep 17 00:00:00 2001 From: "Spruit, Neil R" Date: Tue, 7 Mar 2023 19:30:25 +0000 Subject: [PATCH] Add check allowing 1_2 device properties in stype check Signed-off-by: Spruit, Neil R --- level_zero/core/source/device/device_imp.cpp | 2 +- .../sources/device/device_drm/test_device.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/level_zero/core/source/device/device_imp.cpp b/level_zero/core/source/device/device_imp.cpp index 2aab1e2a2b..7acd18940b 100644 --- a/level_zero/core/source/device/device_imp.cpp +++ b/level_zero/core/source/device/device_imp.cpp @@ -838,7 +838,7 @@ ze_result_t DeviceImp::getProperties(ze_device_properties_t *pDeviceProperties) ze_base_properties_t *extendedProperties = reinterpret_cast(pDeviceProperties->pNext); - bool isDevicePropertiesStypeValid = (pDeviceProperties->stype == ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES) ? true : false; + bool isDevicePropertiesStypeValid = (pDeviceProperties->stype == ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES || pDeviceProperties->stype == ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES_1_2) ? true : false; if (isDevicePropertiesStypeValid) { while (extendedProperties) { diff --git a/level_zero/core/test/unit_tests/sources/device/device_drm/test_device.cpp b/level_zero/core/test/unit_tests/sources/device/device_drm/test_device.cpp index ea5699f3dc..9d74cfb108 100644 --- a/level_zero/core/test/unit_tests/sources/device/device_drm/test_device.cpp +++ b/level_zero/core/test/unit_tests/sources/device/device_drm/test_device.cpp @@ -33,6 +33,16 @@ TEST_F(LuidDeviceTest, givenLuidDevicePropertiesStructureAndDRMDriverTypeThenUns EXPECT_EQ(result, ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); } +TEST_F(LuidDeviceTest, givenLuidDevicePropertiesStructureAndNewValidStypeWithDRMDriverTypeThenUnsupportedReturned) { + neoDevice->executionEnvironment->rootDeviceEnvironments[0]->osInterface.reset(new NEO::OSInterface()); + neoDevice->executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::make_unique()); + ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES_1_2}; + ze_device_luid_ext_properties_t deviceLuidProperties = {ZE_STRUCTURE_TYPE_DEVICE_LUID_EXT_PROPERTIES}; + deviceProperties.pNext = &deviceLuidProperties; + ze_result_t result = device->getProperties(&deviceProperties); + EXPECT_EQ(result, ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); +} + TEST_F(LuidDeviceTest, givenLuidDevicePropertiesStructureAndStypeIsIncorrectThenpNextIsNotDereferenced) { neoDevice->executionEnvironment->rootDeviceEnvironments[0]->osInterface.reset(new NEO::OSInterface()); neoDevice->executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::make_unique());