Skip to content

Commit 923b905

Browse files
committed
Fixed TimerGetElapsedTime race conditions
In rare cases, a second (identical) call to TimerGetElapsedTime may return a different value, due to the clock progressing between calls. In even rarer cases, this may lead to unintended zero values or even wraps, that lead to logic errors later on.
1 parent a261eba commit 923b905

File tree

10 files changed

+10
-10
lines changed

10 files changed

+10
-10
lines changed

src/mac/region/RegionAS923.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@ LoRaMacStatus_t RegionAS923NextChannel( NextChanParams_t* nextChanParams, uint8_
918918
}
919919

920920
TimerTime_t elapsed = TimerGetElapsedTime( nextChanParams->LastAggrTx );
921-
if( ( nextChanParams->LastAggrTx == 0 ) || ( nextChanParams->AggrTimeOff <= elapsed ) )
921+
if( nextChanParams->AggrTimeOff <= elapsed )
922922
{
923923
// Reset Aggregated time off
924924
*aggregatedTimeOff = 0;

src/mac/region/RegionAU915.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@ LoRaMacStatus_t RegionAU915NextChannel( NextChanParams_t* nextChanParams, uint8_
918918
}
919919

920920
TimerTime_t elapsed = TimerGetElapsedTime( nextChanParams->LastAggrTx );
921-
if( ( nextChanParams->LastAggrTx == 0 ) || ( nextChanParams->AggrTimeOff <= elapsed ) )
921+
if( nextChanParams->AggrTimeOff <= elapsed )
922922
{
923923
// Reset Aggregated time off
924924
*aggregatedTimeOff = 0;

src/mac/region/RegionCN470.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ LoRaMacStatus_t RegionCN470NextChannel( NextChanParams_t* nextChanParams, uint8_
735735
}
736736

737737
TimerTime_t elapsed = TimerGetElapsedTime( nextChanParams->LastAggrTx );
738-
if( ( nextChanParams->LastAggrTx == 0 ) || ( nextChanParams->AggrTimeOff <= elapsed ) )
738+
if( nextChanParams->AggrTimeOff <= elapsed )
739739
{
740740
// Reset Aggregated time off
741741
*aggregatedTimeOff = 0;

src/mac/region/RegionCN779.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ LoRaMacStatus_t RegionCN779NextChannel( NextChanParams_t* nextChanParams, uint8_
861861
}
862862

863863
TimerTime_t elapsed = TimerGetElapsedTime( nextChanParams->LastAggrTx );
864-
if( ( nextChanParams->LastAggrTx == 0 ) || ( nextChanParams->AggrTimeOff <= elapsed ) )
864+
if( nextChanParams->AggrTimeOff <= elapsed )
865865
{
866866
// Reset Aggregated time off
867867
*aggregatedTimeOff = 0;

src/mac/region/RegionEU433.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ LoRaMacStatus_t RegionEU433NextChannel( NextChanParams_t* nextChanParams, uint8_
861861
}
862862

863863
TimerTime_t elapsed = TimerGetElapsedTime( nextChanParams->LastAggrTx );
864-
if( ( nextChanParams->LastAggrTx == 0 ) || ( nextChanParams->AggrTimeOff <= elapsed ) )
864+
if( nextChanParams->AggrTimeOff <= elapsed )
865865
{
866866
// Reset Aggregated time off
867867
*aggregatedTimeOff = 0;

src/mac/region/RegionEU868.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@ LoRaMacStatus_t RegionEU868NextChannel( NextChanParams_t* nextChanParams, uint8_
893893
}
894894

895895
TimerTime_t elapsed = TimerGetElapsedTime( nextChanParams->LastAggrTx );
896-
if( ( nextChanParams->LastAggrTx == 0 ) || ( nextChanParams->AggrTimeOff <= elapsed ) )
896+
if( nextChanParams->AggrTimeOff <= elapsed )
897897
{
898898
// Reset Aggregated time off
899899
*aggregatedTimeOff = 0;

src/mac/region/RegionIN865.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,7 @@ LoRaMacStatus_t RegionIN865NextChannel( NextChanParams_t* nextChanParams, uint8_
886886
}
887887

888888
TimerTime_t elapsed = TimerGetElapsedTime( nextChanParams->LastAggrTx );
889-
if( ( nextChanParams->LastAggrTx == 0 ) || ( nextChanParams->AggrTimeOff <= elapsed ) )
889+
if( nextChanParams->AggrTimeOff <= elapsed )
890890
{
891891
// Reset Aggregated time off
892892
*aggregatedTimeOff = 0;

src/mac/region/RegionKR920.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,7 @@ LoRaMacStatus_t RegionKR920NextChannel( NextChanParams_t* nextChanParams, uint8_
855855
}
856856

857857
TimerTime_t elapsed = TimerGetElapsedTime( nextChanParams->LastAggrTx );
858-
if( ( nextChanParams->LastAggrTx == 0 ) || ( nextChanParams->AggrTimeOff <= elapsed ) )
858+
if( nextChanParams->AggrTimeOff <= elapsed )
859859
{
860860
// Reset Aggregated time off
861861
*aggregatedTimeOff = 0;

src/mac/region/RegionRU864.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,7 @@ LoRaMacStatus_t RegionRU864NextChannel( NextChanParams_t* nextChanParams, uint8_
857857
}
858858

859859
TimerTime_t elapsed = TimerGetElapsedTime( nextChanParams->LastAggrTx );
860-
if( ( nextChanParams->LastAggrTx == 0 ) || ( nextChanParams->AggrTimeOff <= elapsed ) )
860+
if( nextChanParams->AggrTimeOff <= elapsed )
861861
{
862862
// Reset Aggregated time off
863863
*aggregatedTimeOff = 0;

src/mac/region/RegionUS915.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,7 @@ LoRaMacStatus_t RegionUS915NextChannel( NextChanParams_t* nextChanParams, uint8_
10101010
}
10111011

10121012
TimerTime_t elapsed = TimerGetElapsedTime( nextChanParams->LastAggrTx );
1013-
if( ( nextChanParams->LastAggrTx == 0 ) || ( nextChanParams->AggrTimeOff <= elapsed ) )
1013+
if( nextChanParams->AggrTimeOff <= elapsed )
10141014
{
10151015
// Reset Aggregated time off
10161016
*aggregatedTimeOff = 0;

0 commit comments

Comments
 (0)