Explorar el Código

qcacmn: Add NULL check for WMI handle

Adding NULL checks for WMI handle while registering or unregistering
events or event handlers

Change-Id: Icdf7032bad7289e62f5d7b17aab9780bcdf0ab1d
Akshay Kosigi hace 6 años
padre
commit
46050aa104
Se han modificado 1 ficheros con 24 adiciones y 3 borrados
  1. 24 3
      wmi/src/wmi_unified.c

+ 24 - 3
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) {