Add max iteration limit to prevent infinite loops in nrfx_gpiote.c#132
Open
PwnVerse wants to merge 1 commit intoNordicSemiconductor:masterfrom
Open
Add max iteration limit to prevent infinite loops in nrfx_gpiote.c#132PwnVerse wants to merge 1 commit intoNordicSemiconductor:masterfrom
PwnVerse wants to merge 1 commit intoNordicSemiconductor:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The
input_read_and_checkcan 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 thedo-whileloop inport_event_handlefunction breaks after executing enough number of iterations which otherwise would remain stuck in an infinite loop.Patch
This patch adds
max_iterationsdepending on theGPIO_COUNTand ensures that the loop breaks out in a scenario whereinput_read_and_checknever returns false. Multiplying it with32accounts 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 with3provides an additional margin to handle subtle fluctuations or hardware anomalies, ensuring the loop terminates in case of brief external noise or edge cases.