Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2a8824c6 authored by Rongjing Liao's avatar Rongjing Liao Committed by nshrivas
Browse files

qcacmn: add pointer NULL check in spectral module

Add pointer NULL check before use in spectral module.

Change-Id: I018c52a175157605463c23cce95d78ffea23b867
CRs-Fixed: 2643196
parent b98c7209
Loading
Loading
Loading
Loading
+86 −5
Original line number Diff line number Diff line
@@ -3086,8 +3086,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;
@@ -3664,6 +3675,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");
@@ -3676,10 +3692,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");
@@ -3687,6 +3699,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;
@@ -3886,8 +3902,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;
@@ -3913,8 +3940,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;
@@ -4215,6 +4253,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));

@@ -4237,6 +4280,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));

@@ -4281,6 +4329,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)
@@ -4302,6 +4356,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;
}

@@ -4333,8 +4393,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);
}

@@ -4411,6 +4481,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,
@@ -4421,7 +4503,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,