[link-metrics] fix race condition (#9986)

The CL cherry-picks the fix of link metrics race condition.

Bug: 331743760
Test: None
Change-Id: Id3efcea4ad322293d25048eec936c66b0add3eab
Reviewed-on: https://fuchsia-review.googlesource.com/c/third_party/openthread/+/1030332
Reviewed-by: Sundarajan Srinivasan <sundarsrini@google.com>
diff --git a/src/core/mac/mac_frame.cpp b/src/core/mac/mac_frame.cpp
index 3e84465..9946bb2 100644
--- a/src/core/mac/mac_frame.cpp
+++ b/src/core/mac/mac_frame.cpp
@@ -1220,9 +1220,11 @@
 {
     uint8_t *cur = GetThreadIe(ThreadIe::kEnhAckProbingIe);
 
-    OT_ASSERT(cur != nullptr);
-
+    VerifyOrExit(cur != nullptr);
     memcpy(cur + sizeof(HeaderIe) + sizeof(VendorIeHeader), aValue, aLen);
+
+exit:
+    return;
 }
 #endif // OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE