Repository navigation
Reject servo mixer inputs from RC channels 19-34 on boards without them - #12284
sensei-hacker wants to merge 1 commit into
Conversation
servoMixer() fills the RC channel 19-34 inputs only when USE_34CHANNELS is defined, but smix and both MSP setters accepted them on every board. On a 512 KB board a rule using one of them drove its servo from uninitialized stack memory. The MSP setters also accepted any input number at all, reading past the end of the input array. smix and both MSP setters now refuse an input the board cannot fill. A rule already saved with one is skipped, and blocks arming as an invalid setting; CLI status says which problem it is.
|
ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing |
PR Summary by QodoReject servo mixer inputs from RC channels 19-34 on boards without them
AI Description
Merge Risk
|
Code Review by Qodo
1. Rejected mixer rules appear saved
|
|
RAM / Flash usage vs. base commit
See RAM/flash optimization guide for techniques to reduce usage. |
Problem
servoMixer()keeps its inputs in an array on the stack that is never zeroed,int16_t input[INPUT_SOURCE_COUNT]. It fills the RC channel 19–34 inputs only whenUSE_34CHANNELSis defined, and that is off on 512 KB boards such as the F411.Even so,
smixand both MSP setters accepted those inputs on every board. On a board withoutUSE_34CHANNELS, a servo rule with input 44–59 (RC channel 19–34) drives its servo from whatever value is left in that stack memory.There is a second problem in the MSP setters,
MSP_SET_SERVO_MIX_RULEandMSP2_INAV_SET_SERVO_MIXER. They didn't check the input number at all, so an out-of-range input was read past the end ofinput[].Changes
servoMixerInputSupported()rejects RC channel 19–34 inputs on boards withoutUSE_34CHANNELS, and any input outside the defined range.smix,MSP_SET_SERVO_MIX_RULEandMSP2_INAV_SET_SERVO_MIXERrefuse such an input. The MSP setters reply with an error and change nothing.SETTINGFAIL).statusexplains why: "Servo mixer rule uses an input this board does not support".Testing
The test script is
servo_mixer_input_check.py. It sends rules with input 43 (RC channel 18), 45 (RC channel 20) and 316 (which is 60 when cut to 8 bits) over the CLI and both MSP commands. It also checks the arming flag and thestatustext for a rule that is already saved.USE_34CHANNELS)USE_34CHANNELS)statusgives the reasonUSE_34CHANNELS(SITL built with its real flash size, #12281)Not covered here