Skip to content

Commit 77c5150

Browse files
authored
Properly use critical region
Protect the LoRaMacClassBEvents between read an reset in the critical region
1 parent 12fdb3a commit 77c5150

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/mac/LoRaMacClassB.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1651,13 +1651,15 @@ void LoRaMacClassBSetMulticastPeriodicity( MulticastCtx_t* multicastChannel )
16511651
void LoRaMacClassBProcess( void )
16521652
{
16531653
#ifdef LORAMAC_CLASSB_ENABLED
1654-
LoRaMacClassBEvents_t events = LoRaMacClassBEvents;
1654+
LoRaMacClassBEvents_t events;
1655+
1656+
CRITICAL_SECTION_BEGIN( );
1657+
events = LoRaMacClassBEvents;
1658+
LoRaMacClassBEvents.Value = 0;
1659+
CRITICAL_SECTION_END( );
1660+
16551661
if( events.Value != 0 )
16561662
{
1657-
CRITICAL_SECTION_BEGIN( );
1658-
LoRaMacClassBEvents.Value = 0;
1659-
CRITICAL_SECTION_END( );
1660-
16611663
if( events.Events.Beacon == 1 )
16621664
{
16631665
LoRaMacClassBProcessBeacon( );

0 commit comments

Comments
 (0)