From 57b0f533bb744cc6bd6f1b66ff5c63c9c47616e2 Mon Sep 17 00:00:00 2001 From: Zhanglong Xia Date: Sat, 14 Dec 2019 04:05:52 +0800 Subject: [PATCH] [posix-host] update the function IsSafeToHandleNow() to avoid re-entrant issue (#4407) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit mWaitingKey != SPINEL_PROP_LAST_STATUS means the NCP is waiting for a spinel response from RCP. When mWaitingKey is set to SPINEL_PROP_LAST_STATUS and HdlcInterface receives a ChildIdResponse message from RCP,HdlcInterface calls the function Decode() to decode the received HDLC frame. Then the decoded spinel frame is sent to RadioSpinel module. Because the function IsSafeToHandleNow() returns true now, the RadioSpinel sends the received ChildIdResponse frame to up layer immediately. Then the MLE layer calls the function otPlatRadioSetShortAddress() to set short address. The function otPlatRadioSetShortAddress() sends spinel frame MAC_15_4_SADDR to RCP and waits for the spinel response. When the response frame is received, the HdlcInterface calls the function Decode() again, the function Decode() uses previous calculated FCS value to calculate the current received HDLC frame. The wrong FCS value caused the parsing error for the received response frame. --- src/posix/platform/radio_spinel.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/posix/platform/radio_spinel.hpp b/src/posix/platform/radio_spinel.hpp index 6b03dc602..34781c8a4 100644 --- a/src/posix/platform/radio_spinel.hpp +++ b/src/posix/platform/radio_spinel.hpp @@ -624,8 +624,7 @@ private: */ bool IsSafeToHandleNow(spinel_prop_key_t aKey) const { - return !((mWaitingKey != SPINEL_PROP_LAST_STATUS) && - (aKey == SPINEL_PROP_STREAM_RAW || aKey == SPINEL_PROP_MAC_ENERGY_SCAN_RESULT)); + return !(aKey == SPINEL_PROP_STREAM_RAW || aKey == SPINEL_PROP_MAC_ENERGY_SCAN_RESULT); } void HandleNotification(HdlcInterface::RxFrameBuffer &aFrameBuffer);