From 355fc7bd7e40c6fd3f446e40abb2126d4ec8f9d4 Mon Sep 17 00:00:00 2001 From: jflyper Date: Sat, 4 May 2019 11:13:25 +0900 Subject: [PATCH] Protect against null timerHardware --- src/main/drivers/light_ws2811strip_hal.c | 5 +++++ src/main/drivers/light_ws2811strip_stdperiph.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/main/drivers/light_ws2811strip_hal.c b/src/main/drivers/light_ws2811strip_hal.c index 9f4b1deda8..c121f901d7 100644 --- a/src/main/drivers/light_ws2811strip_hal.c +++ b/src/main/drivers/light_ws2811strip_hal.c @@ -58,6 +58,11 @@ bool ws2811LedStripHardwareInit(ioTag_t ioTag) } const timerHardware_t *timerHardware = timerGetByTag(ioTag); + + if (timerHardware == NULL) { + return false; + } + TIM_TypeDef *timer = timerHardware->tim; timerChannel = timerHardware->channel; diff --git a/src/main/drivers/light_ws2811strip_stdperiph.c b/src/main/drivers/light_ws2811strip_stdperiph.c index d42471c475..10200b292f 100644 --- a/src/main/drivers/light_ws2811strip_stdperiph.c +++ b/src/main/drivers/light_ws2811strip_stdperiph.c @@ -86,6 +86,11 @@ bool ws2811LedStripHardwareInit(ioTag_t ioTag) DMA_InitTypeDef DMA_InitStructure; const timerHardware_t *timerHardware = timerGetByTag(ioTag); + + if (timerHardware == NULL) { + return false; + } + timer = timerHardware->tim; #if defined(USE_DMA_SPEC)