From 16c207825ff9a004ebdbd64e90af45267d078810 Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Wed, 4 Aug 2021 22:45:13 -0700 Subject: [PATCH] [mle] ensure Link Metrics methods free newly allocated msg on error (#6889) This commit fixes methods `SendLinkMetricsManagementResponse()`, `SendLinkMetricsManagementRequest()` and `SendLinkProbe()` in `Mle` to ensure that the allocated MLE message is freed on an error. Note that on success the `Mle::SendMessage()` will take the ownership of the allocated `Message`. --- src/core/thread/mle.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/core/thread/mle.cpp b/src/core/thread/mle.cpp index 078b65b1d..8d6e13c4e 100644 --- a/src/core/thread/mle.cpp +++ b/src/core/thread/mle.cpp @@ -2532,7 +2532,9 @@ Error Mle::SendLinkMetricsManagementResponse(const Ip6::Address &aDestination, L SuccessOrExit(error = message->Append(aStatus)); SuccessOrExit(error = SendMessage(*message, aDestination)); + exit: + FreeMessageOnError(message, error); return error; } #endif @@ -2555,7 +2557,9 @@ Error Mle::SendLinkProbe(const Ip6::Address &aDestination, uint8_t aSeriesId, ui SuccessOrExit(error = message->AppendBytes(aBuf, aLength)); SuccessOrExit(error = SendMessage(*message, aDestination)); + exit: + FreeMessageOnError(message, error); return error; } #endif @@ -4495,6 +4499,7 @@ Error Mle::SendLinkMetricsManagementRequest(const Ip6::Address &aDestination, co SuccessOrExit(error = SendMessage(*message, aDestination)); exit: + FreeMessageOnError(message, error); return error; } #endif