Skip to content

Commit

Permalink
kfdtest: fix resource leakage
Browse files Browse the repository at this point in the history
Resource allocated in SetUp/HsaNodeInfo::Init,
needs be delete in TearDown/HsaNodeInfo::Delete.

Signed-off-by: James Zhu <[email protected]>
  • Loading branch information
jameszhu-amd committed Feb 25, 2025
1 parent 322a794 commit f8d8b80
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions libhsakmt/tests/kfdtest/src/KFDBaseComponentTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ void KFDBaseComponentTest::TearDown() {

closelog();

m_NodeInfo.Delete();
ROUTINE_END
}

Expand Down
8 changes: 7 additions & 1 deletion libhsakmt/tests/kfdtest/src/KFDTestUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,13 +609,19 @@ bool HsaNodeInfo::Init(int NumOfNodes) {
return ret;
}

HsaNodeInfo::~HsaNodeInfo() {
void HsaNodeInfo::Delete() {
const HsaNodeProperties *nodeProperties;

for (unsigned int i = 0; i < m_HsaNodeProps.size(); i++)
delete m_HsaNodeProps.at(i);

m_HsaNodeProps.clear();
m_NodesWithGPU.clear();
m_NodesWithoutGPU.clear();
}

HsaNodeInfo::~HsaNodeInfo() {
Delete();
}

const std::vector<int>& HsaNodeInfo::GetNodesWithGPU() const {
Expand Down
1 change: 1 addition & 0 deletions libhsakmt/tests/kfdtest/src/KFDTestUtil.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ class HsaNodeInfo {
~HsaNodeInfo();

bool Init(int NumOfNodes);
void Delete();

/* This function should be deprecated soon. This for transistion purpose only
* Currently, KfdTest is designed to test only ONE node. This function acts
Expand Down

0 comments on commit f8d8b80

Please sign in to comment.