From 9babc67597ecbad685fd56c3ee8a57955fd7911e Mon Sep 17 00:00:00 2001 From: Amar Singhal Date: Tue, 4 Sep 2018 12:46:25 -0700 Subject: [PATCH] qcacld-3.0: Check if NAPI ptr is NULL Check if pointer returned by hdd_napi_get_all is NULL. This would prevent de-referencing of NULL pointer. Change-Id: I23af3319422e0d2ebd93ce410d76457c54551538 CRs-Fixed: 2299788 --- core/hdd/src/wlan_hdd_napi.c | 64 ++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 28 deletions(-) diff --git a/core/hdd/src/wlan_hdd_napi.c b/core/hdd/src/wlan_hdd_napi.c index a64f3138b329..b7c04764367d 100644 --- a/core/hdd/src/wlan_hdd_napi.c +++ b/core/hdd/src/wlan_hdd_napi.c @@ -102,40 +102,48 @@ int hdd_napi_create(void) NAPI_DEBUG("-->"); + if (NULL == napid) { + hdd_err("unable to retrieve napi structure"); + rc = -EFAULT; + goto exit; + } + hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); if (unlikely(NULL == hif_ctx)) { QDF_ASSERT(NULL != hif_ctx); rc = -EFAULT; - } else { - - feature_flags = QCA_NAPI_FEATURE_CPU_CORRECTION | - QCA_NAPI_FEATURE_IRQ_BLACKLISTING | - QCA_NAPI_FEATURE_CORE_CTL_BOOST; - - rc = hif_napi_create(hif_ctx, hdd_napi_poll, - QCA_NAPI_BUDGET, - QCA_NAPI_DEF_SCALE, - feature_flags); - if (rc < 0) { - hdd_err("ERR(%d) creating NAPI instances", - rc); - } else { - hdd_debug("napi instances were created. Map=0x%x", rc); - hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); - if (unlikely(NULL == hdd_ctx)) { - QDF_ASSERT(0); - rc = -EFAULT; - } else { - rc = hdd_napi_event(NAPI_EVT_INI_FILE, - (void *)hdd_ctx->napi_enable); - napid->user_cpu_affin_mask = - hdd_ctx->config->napi_cpu_affinity_mask; - } - } - + goto exit; } - NAPI_DEBUG("<-- [rc=%d]", rc); + feature_flags = QCA_NAPI_FEATURE_CPU_CORRECTION | + QCA_NAPI_FEATURE_IRQ_BLACKLISTING | + QCA_NAPI_FEATURE_CORE_CTL_BOOST; + + rc = hif_napi_create(hif_ctx, hdd_napi_poll, + QCA_NAPI_BUDGET, + QCA_NAPI_DEF_SCALE, + feature_flags); + if (rc < 0) { + hdd_err("ERR(%d) creating NAPI instances", + rc); + goto exit; + } + + hdd_debug("napi instances were created. Map=0x%x", rc); + hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); + if (unlikely(NULL == hdd_ctx)) { + QDF_ASSERT(0); + rc = -EFAULT; + goto exit; + } + + rc = hdd_napi_event(NAPI_EVT_INI_FILE, + (void *)hdd_ctx->napi_enable); + napid->user_cpu_affin_mask = + hdd_ctx->config->napi_cpu_affinity_mask; + + exit: + NAPI_DEBUG("<-- [rc=%d]", rc); return rc; }