mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-21 09:14:47 +08:00
fix: avoid double free when wddm initialization fails
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
90e24a433d
commit
038c287656
@@ -64,7 +64,7 @@ class ProductHelper {
|
|||||||
|
|
||||||
static constexpr uint32_t uuidSize = 16u;
|
static constexpr uint32_t uuidSize = 16u;
|
||||||
static constexpr uint32_t luidSize = 8u;
|
static constexpr uint32_t luidSize = 8u;
|
||||||
int configureHwInfoWddm(const HardwareInfo *inHwInfo, HardwareInfo *outHwInfo, const RootDeviceEnvironment &rootDeviceEnvironment);
|
MOCKABLE_VIRTUAL int configureHwInfoWddm(const HardwareInfo *inHwInfo, HardwareInfo *outHwInfo, const RootDeviceEnvironment &rootDeviceEnvironment);
|
||||||
int configureHwInfoDrm(const HardwareInfo *inHwInfo, HardwareInfo *outHwInfo, const RootDeviceEnvironment &rootDeviceEnvironment);
|
int configureHwInfoDrm(const HardwareInfo *inHwInfo, HardwareInfo *outHwInfo, const RootDeviceEnvironment &rootDeviceEnvironment);
|
||||||
virtual int configureHardwareCustom(HardwareInfo *hwInfo, OSInterface *osIface) const = 0;
|
virtual int configureHardwareCustom(HardwareInfo *hwInfo, OSInterface *osIface) const = 0;
|
||||||
virtual void adjustPlatformForProductFamily(HardwareInfo *hwInfo) = 0;
|
virtual void adjustPlatformForProductFamily(HardwareInfo *hwInfo) = 0;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2021 Intel Corporation
|
* Copyright (C) 2021-2023 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
@@ -19,7 +19,6 @@ bool initWddmOsInterface(std::unique_ptr<HwDeviceId> &&hwDeviceId, RootDeviceEnv
|
|||||||
auto hwDeviceIdWddm = std::unique_ptr<HwDeviceIdWddm>(reinterpret_cast<HwDeviceIdWddm *>(hwDeviceId.release()));
|
auto hwDeviceIdWddm = std::unique_ptr<HwDeviceIdWddm>(reinterpret_cast<HwDeviceIdWddm *>(hwDeviceId.release()));
|
||||||
NEO::Wddm *wddm = Wddm::createWddm(std::move(hwDeviceIdWddm), *rootDeviceEnv);
|
NEO::Wddm *wddm = Wddm::createWddm(std::move(hwDeviceIdWddm), *rootDeviceEnv);
|
||||||
if (!wddm->init()) {
|
if (!wddm->init()) {
|
||||||
delete wddm;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
rootDeviceEnv->memoryOperationsInterface = std::make_unique<WddmMemoryOperationsHandler>(wddm);
|
rootDeviceEnv->memoryOperationsInterface = std::make_unique<WddmMemoryOperationsHandler>(wddm);
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ bool Wddm::init() {
|
|||||||
rootDeviceEnvironment.osInterface = std::make_unique<OSInterface>();
|
rootDeviceEnvironment.osInterface = std::make_unique<OSInterface>();
|
||||||
rootDeviceEnvironment.osInterface->setDriverModel(std::unique_ptr<DriverModel>(this));
|
rootDeviceEnvironment.osInterface->setDriverModel(std::unique_ptr<DriverModel>(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!queryAdapterInfo()) {
|
if (!queryAdapterInfo()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,5 +16,6 @@ struct MockProductHelper : ProductHelperHw<IGFX_UNKNOWN> {
|
|||||||
MockProductHelper() = default;
|
MockProductHelper() = default;
|
||||||
|
|
||||||
ADDMETHOD_CONST_NOBASE(is48bResourceNeededForRayTracing, bool, true, ());
|
ADDMETHOD_CONST_NOBASE(is48bResourceNeededForRayTracing, bool, true, ());
|
||||||
|
ADDMETHOD_NOBASE(configureHwInfoWddm, int, 0, (const HardwareInfo *inHwInfo, HardwareInfo *outHwInfo, const RootDeviceEnvironment &rootDeviceEnvironment));
|
||||||
};
|
};
|
||||||
} // namespace NEO
|
} // namespace NEO
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||||
#include "shared/test/common/mocks/mock_gmm_client_context_base.h"
|
#include "shared/test/common/mocks/mock_gmm_client_context_base.h"
|
||||||
#include "shared/test/common/mocks/mock_io_functions.h"
|
#include "shared/test/common/mocks/mock_io_functions.h"
|
||||||
|
#include "shared/test/common/mocks/mock_product_helper.h"
|
||||||
#include "shared/test/common/os_interface/windows/wddm_fixture.h"
|
#include "shared/test/common/os_interface/windows/wddm_fixture.h"
|
||||||
#include "shared/test/common/test_macros/hw_test.h"
|
#include "shared/test/common/test_macros/hw_test.h"
|
||||||
|
|
||||||
@@ -650,4 +651,17 @@ TEST(WddmAllocationTest, whenAllocationIsNotShareableThenItDoesntReturnSharedHan
|
|||||||
int ret = allocation.peekInternalHandle(nullptr, handle);
|
int ret = allocation.peekInternalHandle(nullptr, handle);
|
||||||
EXPECT_NE(ret, 0);
|
EXPECT_NE(ret, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(WddmTests, whenInitializeFailureThenInitOsInterfaceWddmFails) {
|
||||||
|
|
||||||
|
auto hwDeviceId = std::make_unique<HwDeviceIdWddm>(0, LUID{0, 0}, 1u, executionEnvironment->osEnvironment.get(), nullptr);
|
||||||
|
|
||||||
|
rootDeviceEnvironment->osInterface.reset();
|
||||||
|
auto productHelper = std::make_unique<MockProductHelper>();
|
||||||
|
productHelper->configureHwInfoWddmResult = 1; // failure
|
||||||
|
rootDeviceEnvironment->productHelper = std::move(productHelper);
|
||||||
|
|
||||||
|
EXPECT_FALSE(rootDeviceEnvironment->initOsInterface(std::move(hwDeviceId), 0u));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace NEO
|
} // namespace NEO
|
||||||
|
|||||||
Reference in New Issue
Block a user