From c52188f0bf188940bb2bf56cec141da15a27aeaa Mon Sep 17 00:00:00 2001 From: raiden00pl Date: Mon, 2 Oct 2023 12:53:04 +0200 Subject: [PATCH] drivers/foc/foc_dummy.c: update dummy device state only if dev opened This is fix for seg fault for sim/foc configuration --- drivers/motor/foc/foc_dummy.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/motor/foc/foc_dummy.c b/drivers/motor/foc/foc_dummy.c index 75582439e3..0766da48c5 100644 --- a/drivers/motor/foc/foc_dummy.c +++ b/drivers/motor/foc/foc_dummy.c @@ -687,13 +687,18 @@ void foc_dummy_update(void) dev = &g_foc_dev[i]; - /* Get SIM data */ + /* Update dummy driver state only if device opened */ - sim = FOC_DUMMY_DATA_FROM_DEV_GET(dev); - - if (sim->state == true) + if (dev->ocount > 0) { - foc_dummy_notifier_handler(dev); + /* Get SIM data */ + + sim = FOC_DUMMY_DATA_FROM_DEV_GET(dev); + + if (sim->state == true) + { + foc_dummy_notifier_handler(dev); + } } }