From 1289536e72c82ffc2d599b65e341b323243fbdd6 Mon Sep 17 00:00:00 2001 From: zwx Date: Mon, 29 Dec 2025 10:46:37 +0800 Subject: [PATCH] [mac] clear mode2 key only on mac destruction --- src/core/mac/mac.hpp | 5 +++++ src/core/thread/key_manager.cpp | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/core/mac/mac.hpp b/src/core/mac/mac.hpp index 790823b73..7d7ca9083 100644 --- a/src/core/mac/mac.hpp +++ b/src/core/mac/mac.hpp @@ -134,6 +134,11 @@ public: */ explicit Mac(Instance &aInstance); + /** + * Clears the Mode2Key on destruction. + */ + ~Mac(void) { ClearMode2Key(); } + /** * Starts an IEEE 802.15.4 Active Scan. * diff --git a/src/core/thread/key_manager.cpp b/src/core/thread/key_manager.cpp index d520d8162..f98793a7a 100644 --- a/src/core/thread/key_manager.cpp +++ b/src/core/thread/key_manager.cpp @@ -691,7 +691,6 @@ void KeyManager::DestroyTemporaryKeys(void) mMleKey.Clear(); mKek.Clear(); Get().ClearMacKeys(); - Get().ClearMode2Key(); } void KeyManager::DestroyPersistentKeys(void) { Get().DestroyPersistentKeys(); }