From 0cc44098451b87275958ad203826499e590826b4 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 13 Feb 2021 09:36:04 +1100 Subject: [PATCH] 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 --- libraries/AP_HAL_ChibiOS/RCOutput.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/AP_HAL_ChibiOS/RCOutput.cpp b/libraries/AP_HAL_ChibiOS/RCOutput.cpp index 39f48b5a91..0875a27309 100644 --- a/libraries/AP_HAL_ChibiOS/RCOutput.cpp +++ b/libraries/AP_HAL_ChibiOS/RCOutput.cpp @@ -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; nserial_nleds; n++) {