From 3a84144b1e693b1293757c487f7f398efbed515d Mon Sep 17 00:00:00 2001 From: Chaitanya Tata Date: Fri, 6 Dec 2024 02:23:31 +0530 Subject: [PATCH] Add proper NULL checking in deinit Add for both RPU context and FMAC context. Signed-off-by: Chaitanya Tata --- nrf70_bm_lib/source/nrf70_bm_core.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/nrf70_bm_lib/source/nrf70_bm_core.c b/nrf70_bm_lib/source/nrf70_bm_core.c index 704659a..aa360db 100644 --- a/nrf70_bm_lib/source/nrf70_bm_core.c +++ b/nrf70_bm_lib/source/nrf70_bm_core.c @@ -638,13 +638,21 @@ int nrf70_fmac_deinit(void) NRF70_LOG_DBG("Deinitializing FMAC module"); #ifndef CONFIG_NRF70_RADIO_TEST - nrf_wifi_fmac_dev_deinit(nrf70_bm_priv.rpu_ctx_bm.rpu_ctx); - nrf_wifi_fmac_dev_rem(nrf70_bm_priv.rpu_ctx_bm.rpu_ctx); - nrf_wifi_fmac_deinit(nrf70_bm_priv.fmac_priv); + if (nrf70_bm_priv.rpu_ctx_bm.rpu_ctx) { + nrf_wifi_fmac_dev_deinit(nrf70_bm_priv.rpu_ctx_bm.rpu_ctx); + nrf_wifi_fmac_dev_rem(nrf70_bm_priv.rpu_ctx_bm.rpu_ctx); + } + if (nrf70_bm_priv.fmac_priv) { + nrf_wifi_fmac_deinit(nrf70_bm_priv.fmac_priv); + } #else - nrf_wifi_fmac_deinit_rt(nrf70_bm_priv.fmac_priv); - nrf_wifi_fmac_dev_rem_rt(nrf70_bm_priv.rpu_ctx_bm.rpu_ctx); - nrf_wifi_fmac_deinit_rt(nrf70_bm_priv.fmac_priv); + if (nrf70_bm_priv.rpu_ctx_bm.rpu_ctx) { + nrf_wifi_fmac_dev_deinit_rt(nrf70_bm_priv.rpu_ctx_bm.rpu_ctx); + nrf_wifi_fmac_dev_rem_rt(nrf70_bm_priv.rpu_ctx_bm.rpu_ctx); + } + if (nrf70_bm_priv.fmac_priv) { + nrf_wifi_fmac_deinit_rt(nrf70_bm_priv.fmac_priv); + } #endif /* CONFIG_NRF70_RADIO_TEST */ nrf70_bm_priv.fmac_priv = NULL;