Browse Source

AP_OpticalFlow: prevent crash on bad device name

master
Andrew Tridgell 7 years ago
parent
commit
ddf8523c2b
  1. 3
      libraries/AP_OpticalFlow/AP_OpticalFlow_Pixart.cpp

3
libraries/AP_OpticalFlow/AP_OpticalFlow_Pixart.cpp

@ -104,6 +104,9 @@ AP_OpticalFlow_Pixart *AP_OpticalFlow_Pixart::detect(OpticalFlow &_frontend) @@ -104,6 +104,9 @@ AP_OpticalFlow_Pixart *AP_OpticalFlow_Pixart::detect(OpticalFlow &_frontend)
// setup the device
bool AP_OpticalFlow_Pixart::setup_sensor(void)
{
if (!_dev) {
return false;
}
if (!_dev->get_semaphore()->take(HAL_SEMAPHORE_BLOCK_FOREVER)) {
AP_HAL::panic("Unable to get bus semaphore");
}

Loading…
Cancel
Save