From d5a4e6488626749bc054ea01bd7a67c1aa2b7756 Mon Sep 17 00:00:00 2001 From: Arif Hussain Date: Wed, 19 Sep 2018 11:28:32 -0700 Subject: [PATCH] qcacmn: Add validation code for wmi handler in dfs module Add validation code for get_wmi_unified_hdl_from_psoc() return to avoid null pointer access. Change-Id: I05a8c135df5197356c77df4997d978c0209b0dfd CRs-Fixed: 2317012 --- target_if/dfs/src/target_if_dfs.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/target_if/dfs/src/target_if_dfs.c b/target_if/dfs/src/target_if_dfs.c index 41f7ee33dad7..311875bbd72a 100644 --- a/target_if/dfs/src/target_if_dfs.c +++ b/target_if/dfs/src/target_if_dfs.c @@ -173,8 +173,15 @@ static QDF_STATUS target_if_reg_phyerr_events_dfs2( struct wlan_objmgr_psoc *psoc) { int ret; + wmi_unified_t wmi_handle; - ret = wmi_unified_register_event(get_wmi_unified_hdl_from_psoc(psoc), + wmi_handle = get_wmi_unified_hdl_from_psoc(psoc); + if (!wmi_handle) { + target_if_err("null wmi_handle"); + return QDF_STATUS_E_INVAL; + } + + ret = wmi_unified_register_event(wmi_handle, wmi_dfs_radar_event_id, target_if_radar_event_handler); if (ret) { @@ -194,7 +201,15 @@ static QDF_STATUS target_if_reg_phyerr_events_dfs2( static bool target_if_dfs_offload(struct wlan_objmgr_psoc *psoc) { - return wmi_service_enabled(get_wmi_unified_hdl_from_psoc(psoc), + wmi_unified_t wmi_handle; + + wmi_handle = get_wmi_unified_hdl_from_psoc(psoc); + if (!wmi_handle) { + target_if_err("null wmi_handle"); + return false; + } + + return wmi_service_enabled(wmi_handle, wmi_service_dfs_phyerr_offload); }