HAL_ChibiOS: fixed handling of invalid channel for LED write

this prevents a null ptr dereference when an invalid channel (such as
one on IOMCU) is used for LEDs
This commit is contained in:
Andrew Tridgell 2021-02-13 09:36:04 +11:00
parent 098a17fe2e
commit 0cc4409845

View File

@ -1979,12 +1979,12 @@ void RCOutput::set_serial_led_rgb_data(const uint16_t chan, int8_t led, uint8_t
uint8_t i = 0;
pwm_group *grp = find_chan(chan, i);
WITH_SEMAPHORE(grp->serial_led_mutex);
if (!grp || grp->serial_nleds == 0) {
return;
}
WITH_SEMAPHORE(grp->serial_led_mutex);
if (led == -1) {
grp->prepared_send = true;
for (uint8_t n=0; n<grp->serial_nleds; n++) {