Skip to content

Add max iteration limit to prevent infinite loops in nrfx_gpiote.c#132

Open
PwnVerse wants to merge 1 commit intoNordicSemiconductor:masterfrom
PwnVerse:patch-1
Open

Add max iteration limit to prevent infinite loops in nrfx_gpiote.c#132
PwnVerse wants to merge 1 commit intoNordicSemiconductor:masterfrom
PwnVerse:patch-1

Conversation

@PwnVerse
Copy link

Description

The input_read_and_check can potentially never return false in case there are fluctuations introduced due to external noise, or faulty hardware. In this case, it becomes essential to ensure that the the do-while loop in port_event_handle function breaks after executing enough number of iterations which otherwise would remain stuck in an infinite loop.

Patch

This patch adds max_iterations depending on the GPIO_COUNT and ensures that the loop breaks out in a scenario where input_read_and_check never returns false. Multiplying it with 32 accounts for the maximum possible number of events that could occur for each GPIO pin, based on the expected event width or number of state changes. Multiplying with 3 provides an additional margin to handle subtle fluctuations or hardware anomalies, ensuring the loop terminates in case of brief external noise or edge cases.

@CLAassistant
Copy link

CLAassistant commented Jan 10, 2025

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants