From 46050aa1042ebdc1a0f6ed7ae597b0b2cac668aa Mon Sep 17 00:00:00 2001 From: Akshay Kosigi Date: Sat, 15 Dec 2018 12:07:43 +0530 Subject: [PATCH] qcacmn: Add NULL check for WMI handle Adding NULL checks for WMI handle while registering or unregistering events or event handlers Change-Id: Icdf7032bad7289e62f5d7b17aab9780bcdf0ab1d --- wmi/src/wmi_unified.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/wmi/src/wmi_unified.c b/wmi/src/wmi_unified.c index 4fc6b9b97e..ce1f43eb6e 100644 --- a/wmi/src/wmi_unified.c +++ b/wmi/src/wmi_unified.c @@ -1798,7 +1798,14 @@ int wmi_unified_register_event(wmi_unified_t wmi_handle, { uint32_t idx = 0; uint32_t evt_id; - struct wmi_soc *soc = wmi_handle->soc; + struct wmi_soc *soc; + + if (!wmi_handle) { + WMI_LOGE("WMI handle is NULL"); + return QDF_STATUS_E_FAILURE; + } + + soc = wmi_handle->soc; if (event_id >= wmi_events_max || wmi_handle->wmi_events[event_id] == WMI_EVENT_ID_INVALID) { @@ -1848,7 +1855,14 @@ int wmi_unified_register_event_handler(wmi_unified_t wmi_handle, { uint32_t idx = 0; uint32_t evt_id; - struct wmi_soc *soc = wmi_handle->soc; + struct wmi_soc *soc; + + if (!wmi_handle) { + WMI_LOGE("WMI handle is NULL"); + return QDF_STATUS_E_FAILURE; + } + + soc = wmi_handle->soc; if (event_id >= wmi_events_max || wmi_handle->wmi_events[event_id] == WMI_EVENT_ID_INVALID) { @@ -1935,7 +1949,14 @@ int wmi_unified_unregister_event_handler(wmi_unified_t wmi_handle, { uint32_t idx = 0; uint32_t evt_id; - struct wmi_soc *soc = wmi_handle->soc; + struct wmi_soc *soc; + + if (!wmi_handle) { + WMI_LOGE("WMI handle is NULL"); + return QDF_STATUS_E_FAILURE; + } + + soc = wmi_handle->soc; if (event_id >= wmi_events_max || wmi_handle->wmi_events[event_id] == WMI_EVENT_ID_INVALID) {