浏览代码

qcacmn: add pointer NULL check in spectral module

Add pointer NULL check before use in spectral module.

Change-Id: I018c52a175157605463c23cce95d78ffea23b867
CRs-Fixed: 2643196
Rongjing Liao 5 年之前
父节点
当前提交
ed684a92f9
共有 1 个文件被更改,包括 86 次插入5 次删除
  1. 86 5
      target_if/spectral/target_if_spectral.c

+ 86 - 5
target_if/spectral/target_if_spectral.c

@@ -3116,8 +3116,19 @@ target_if_get_spectral_config(struct wlan_objmgr_pdev *pdev,
 	struct target_if_spectral *spectral = NULL;
 
 	spectral = get_target_if_spectral_handle_from_pdev(pdev);
+
+	if (!spectral) {
+		spectral_err("SPECTRAL : Module doesn't exist");
+		return QDF_STATUS_E_FAILURE;
+	}
+
 	p_sops = GET_TARGET_IF_SPECTRAL_OPS(spectral);
 
+	if (!p_sops) {
+		spectral_err("p_sops is null");
+		return QDF_STATUS_E_FAILURE;
+	}
+
 	if (smode >= SPECTRAL_SCAN_MODE_MAX) {
 		spectral_err("Invalid Spectral mode %u", smode);
 		return QDF_STATUS_E_FAILURE;
@@ -3920,6 +3931,11 @@ target_if_start_spectral_scan(struct wlan_objmgr_pdev *pdev,
 	}
 	*err = SPECTRAL_SCAN_ERR_INVALID;
 
+	if (!pdev) {
+		spectral_err("pdev object is NUll");
+		return QDF_STATUS_E_FAILURE;
+	}
+
 	psoc = wlan_pdev_get_psoc(pdev);
 	if (!psoc) {
 		spectral_err("psoc is null");
@@ -3932,10 +3948,6 @@ target_if_start_spectral_scan(struct wlan_objmgr_pdev *pdev,
 		return QDF_STATUS_E_FAILURE;
 	}
 
-	if (!pdev) {
-		spectral_err("pdev object is NUll");
-		return QDF_STATUS_E_FAILURE;
-	}
 	spectral = get_target_if_spectral_handle_from_pdev(pdev);
 	if (!spectral) {
 		spectral_err("Spectral LMAC object is NUll");
@@ -3943,6 +3955,10 @@ target_if_start_spectral_scan(struct wlan_objmgr_pdev *pdev,
 	}
 
 	p_sops = GET_TARGET_IF_SPECTRAL_OPS(spectral);
+	if (!p_sops) {
+		spectral_err("p_sops is null");
+		return QDF_STATUS_E_FAILURE;
+	}
 
 	if (smode == SPECTRAL_SCAN_MODE_AGILE) {
 		QDF_STATUS status;
@@ -4143,8 +4159,19 @@ target_if_is_spectral_active(struct wlan_objmgr_pdev *pdev,
 	struct target_if_spectral_ops *p_sops = NULL;
 
 	spectral = get_target_if_spectral_handle_from_pdev(pdev);
+
+	if (!spectral) {
+		spectral_err("SPECTRAL : Module doesn't exist");
+		return QDF_STATUS_E_FAILURE;
+	}
+
 	p_sops = GET_TARGET_IF_SPECTRAL_OPS(spectral);
 
+	if (!p_sops) {
+		spectral_err("p_sops is null");
+		return QDF_STATUS_E_FAILURE;
+	}
+
 	if (smode >= SPECTRAL_SCAN_MODE_MAX) {
 		spectral_err("Invalid Spectral mode %u", smode);
 		return QDF_STATUS_E_FAILURE;
@@ -4170,8 +4197,19 @@ target_if_is_spectral_enabled(struct wlan_objmgr_pdev *pdev,
 	struct target_if_spectral_ops *p_sops = NULL;
 
 	spectral = get_target_if_spectral_handle_from_pdev(pdev);
+
+	if (!spectral) {
+		spectral_err("SPECTRAL : Module doesn't exist");
+		return QDF_STATUS_E_FAILURE;
+	}
+
 	p_sops = GET_TARGET_IF_SPECTRAL_OPS(spectral);
 
+	if (!p_sops) {
+		spectral_err("p_sops is null");
+		return QDF_STATUS_E_FAILURE;
+	}
+
 	if (smode >= SPECTRAL_SCAN_MODE_MAX) {
 		spectral_err("Invalid Spectral mode %u", smode);
 		return QDF_STATUS_E_FAILURE;
@@ -4472,6 +4510,11 @@ target_if_get_spectral_capinfo(struct wlan_objmgr_pdev *pdev,
 	struct target_if_spectral *spectral = NULL;
 
 	spectral = get_target_if_spectral_handle_from_pdev(pdev);
+	if (!spectral) {
+		spectral_err("SPECTRAL : Module doesn't exist");
+		return QDF_STATUS_E_FAILURE;
+	}
+
 	qdf_mem_copy(scaps, &spectral->capability,
 		     sizeof(struct spectral_caps));
 
@@ -4494,6 +4537,11 @@ target_if_get_spectral_diagstats(struct wlan_objmgr_pdev *pdev,
 	struct target_if_spectral *spectral = NULL;
 
 	spectral = get_target_if_spectral_handle_from_pdev(pdev);
+	if (!spectral) {
+		spectral_err("SPECTRAL : Module doesn't exist");
+		return QDF_STATUS_E_FAILURE;
+	}
+
 	qdf_mem_copy(stats, &spectral->diag_stats,
 		     sizeof(struct spectral_diag_stats));
 
@@ -4538,6 +4586,12 @@ target_if_register_netlink_cb(
 	struct target_if_spectral *spectral = NULL;
 
 	spectral = get_target_if_spectral_handle_from_pdev(pdev);
+
+	if (!spectral) {
+		spectral_err("SPECTRAL : Module doesn't exist");
+		return;
+	}
+
 	qdf_mem_copy(&spectral->nl_cb, nl_cb, sizeof(struct spectral_nl_cb));
 
 	if (spectral->use_nl_bcast)
@@ -4559,6 +4613,12 @@ target_if_use_nl_bcast(struct wlan_objmgr_pdev *pdev)
 	struct target_if_spectral *spectral = NULL;
 
 	spectral = get_target_if_spectral_handle_from_pdev(pdev);
+
+	if (!spectral) {
+		spectral_err("SPECTRAL : Module doesn't exist");
+		return false;
+	}
+
 	return spectral->use_nl_bcast;
 }
 
@@ -4590,8 +4650,18 @@ target_if_process_spectral_report(struct wlan_objmgr_pdev *pdev,
 	struct target_if_spectral_ops *p_sops = NULL;
 
 	spectral = get_target_if_spectral_handle_from_pdev(pdev);
+	if (!spectral) {
+		spectral_err("SPECTRAL : Module doesn't exist");
+		return -EPERM;
+	}
+
 	p_sops = GET_TARGET_IF_SPECTRAL_OPS(spectral);
 
+	if (!p_sops) {
+		spectral_err("p_sops is null");
+		return -EPERM;
+	}
+
 	return p_sops->process_spectral_report(pdev, payload);
 }
 
@@ -4668,6 +4738,18 @@ target_if_spectral_send_intf_found_msg(struct wlan_objmgr_pdev *pdev,
 	struct target_if_spectral *spectral = NULL;
 
 	spectral = get_target_if_spectral_handle_from_pdev(pdev);
+
+	if (!spectral) {
+		spectral_err("SPECTRAL : Module doesn't exist");
+		return;
+	}
+
+	p_sops = GET_TARGET_IF_SPECTRAL_OPS(spectral);
+	if (!p_sops) {
+		spectral_err("p_sops is null");
+		return;
+	}
+
 	msg  = (struct spectral_samp_msg *)spectral->nl_cb.get_sbuff(
 			spectral->pdev_obj,
 			SPECTRAL_MSG_INTERFERENCE_NOTIFICATION,
@@ -4678,7 +4760,6 @@ target_if_spectral_send_intf_found_msg(struct wlan_objmgr_pdev *pdev,
 		    SPECTRAL_DCS_INT_CW : SPECTRAL_DCS_INT_WIFI;
 		msg->dcs_enabled = dcs_enabled;
 		msg->signature = SPECTRAL_SIGNATURE;
-		p_sops = GET_TARGET_IF_SPECTRAL_OPS(spectral);
 		p_sops->get_mac_address(spectral, msg->macaddr);
 		if (spectral->send_phy_data
 				(pdev,