Repository navigation
Fix dynamic power headroom underflow when config power lowered while armed - #3639
Merged
pkendall64 merged 1 commit intoMay 19, 2026
Merged
Conversation
When a user lowers their configured max power via Lua while armed, currPower can exceed config.GetPower(). The unsigned subtraction wraps to ~255, bypassing the powerHeadroom > 0 guard and allowing dynamic power to ramp output up to hardware maximum. Guard the subtraction so powerHeadroom is 0 when currPower >= config.
pkendall64
approved these changes
May 11, 2026
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.
Problem
When a user lowers their configured max power via Lua script while armed with dynamic power enabled,
POWERMGNT::currPower()can exceedconfig.GetPower(). The unsigned subtraction on line 117 ofdynpower.cpp:wraps to ~255 (
uint8_tunderflow), causing thepowerHeadroom > 0guards to pass. This allowsincPower()to ramp transmit power up to hardware maximum, exceeding the user's configured limit.On FCC 915MHz and ISM 2400 (non-EU) builds, there is no compile-time cap, so power can reach the hardware maximum. EU CE 2400 builds have a
getMaxPower()cap at 100mW which partially mitigates the issue.Fix
Guard the subtraction so
powerHeadroomis 0 whencurrPower >= configPower:How to reproduce