From fbb155f557d0ab1132ab5fb7efc63b2562d8e1f0 Mon Sep 17 00:00:00 2001 From: "Poddar, Siddarth" Date: Tue, 25 Oct 2016 17:16:38 +0530 Subject: [PATCH] qcacmn: Add NULL check for HIF state and CE state before dereferencing Add NULL check for HIF state and CE state in ce_send_cb_register and ce_recv_cb_register functions before dereferencing it. Change-Id: I96cde91775ff77f6ae863b4d56e48c42e34104c7 CRs-Fixed: 1081995 --- hif/src/ce/ce_service.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/hif/src/ce/ce_service.c b/hif/src/ce/ce_service.c index 1c4d1c534786..61d603152de3 100644 --- a/hif/src/ce/ce_service.c +++ b/hif/src/ce/ce_service.c @@ -2246,13 +2246,19 @@ ce_send_cb_register(struct CE_handle *copyeng, void *ce_send_context, int disable_interrupts) { struct CE_state *CE_state = (struct CE_state *)copyeng; - struct hif_softc *scn = CE_state->scn; - struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn); + struct hif_softc *scn; + struct HIF_CE_state *hif_state; if (CE_state == NULL) { HIF_ERROR("%s: Error CE state = NULL", __func__); return; } + scn = CE_state->scn; + hif_state = HIF_GET_CE_STATE(scn); + if (hif_state == NULL) { + HIF_ERROR("%s: Error HIF state = NULL", __func__); + return; + } CE_state->send_context = ce_send_context; CE_state->send_cb = fn_ptr; hif_state->ce_services->ce_per_engine_handler_adjust(CE_state, @@ -2277,13 +2283,19 @@ ce_recv_cb_register(struct CE_handle *copyeng, void *CE_recv_context, int disable_interrupts) { struct CE_state *CE_state = (struct CE_state *)copyeng; - struct hif_softc *scn = CE_state->scn; - struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn); + struct hif_softc *scn; + struct HIF_CE_state *hif_state; if (CE_state == NULL) { HIF_ERROR("%s: ERROR CE state = NULL", __func__); return; } + scn = CE_state->scn; + hif_state = HIF_GET_CE_STATE(scn); + if (hif_state == NULL) { + HIF_ERROR("%s: Error HIF state = NULL", __func__); + return; + } CE_state->recv_context = CE_recv_context; CE_state->recv_cb = fn_ptr; hif_state->ce_services->ce_per_engine_handler_adjust(CE_state,