A malformed CAN_FILTER_MODIFY message with a bus value of zero produces
bus == -1 after the off-by-one adjustment. The existing bounds check only
tested the upper bound, so hal.can[-1] was dereferenced before validation.
Add a lower-bound check, matching the fix applied to MAV_CMD_CAN_FORWARD.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
we had a deadlock between the mutex in HAL_ChibiOS CAN layer and the
MAVLinkCAN object
the deadlock arose because the low level CAN layer holds the HAL CAN
mutex before it calls up to the MAVLinkCAN frame callback
on the mavlink side, it took the MAVLinkCAN mutex before calling down
to the CAN send layer, this meant it took the 2 mutexes in the
opposite order
the symptoms were:
- failure to boot if we have active MAVCAN during reboot as we
deadlock during the scheduler delay callback
- deadlock during heavy MAVCAN usage