qcacmn: Clean up asserts in Spectral module - Part 7

Clean up invalid pointer/value asserts by returning the error status
to the caller in the below spectral module files
1.target_if_spectral_sim.c

Change-Id: Iad4314409ee5d2037c566c9a022cbfc2444f6460
CRs-Fixed: 3591964
This commit is contained in:
Nagasai Bharat Gatkeshwar Sainoji
2023-08-28 14:45:48 +05:30
committed by Rahul Choudhary
parent 843a02da37
commit 2140bff4e9

View File

@@ -76,7 +76,10 @@ target_if_populate_report_static_gen2(
struct spectralsim_report *report,
enum phy_ch_width width)
{
qdf_assert_always(report);
if (!report) {
spectral_err("report pointer is null.");
goto bad;
}
switch (width) {
case CH_WIDTH_20MHZ:
@@ -203,8 +206,10 @@ target_if_populate_report_static_gen3(
struct spectralsim_report *report,
enum phy_ch_width width)
{
qdf_assert_always(report);
if (!report) {
spectral_err("report pointer is null");
goto bad;
}
switch (width) {
case CH_WIDTH_20MHZ:
report->data = NULL;
@@ -359,7 +364,10 @@ target_if_populate_reportset_static(
int ret = 0;
struct spectralsim_report *report = NULL;
qdf_assert_always(reportset);
if (!reportset) {
spectral_err("reportset pointer is null.");
goto bad;
}
reportset->headreport = NULL;
reportset->curr_report = NULL;
@@ -633,7 +641,10 @@ target_if_spectral_sim_attach(struct target_if_spectral *spectral)
{
struct spectralsim_context *simctx = NULL;
qdf_assert_always(spectral);
if (!spectral) {
spectral_err("Spectral simulation: spectral pointer is null.")
return -EPERM;
}
simctx = (struct spectralsim_context *)
qdf_mem_malloc(sizeof(struct spectralsim_context));
@@ -695,10 +706,15 @@ target_if_spectral_sops_sim_is_active(void *arg)
struct spectralsim_context *simctx = NULL;
spectral = (struct target_if_spectral *)arg;
qdf_assert_always(spectral);
if (!spectral) {
spectral_err("Spectral simulation: spectral pointer is null");
return 0;
}
simctx = (struct spectralsim_context *)spectral->simctx;
qdf_assert_always(simctx);
if (!simctx) {
spectral_err("Spectral simulation: simctx pointer is null");
return 0;
}
return simctx->is_active;
}
@@ -711,10 +727,15 @@ target_if_spectral_sops_sim_is_enabled(void *arg)
struct spectralsim_context *simctx = NULL;
spectral = (struct target_if_spectral *)arg;
qdf_assert_always(spectral);
if (!spectral) {
spectral_err("Spectral simulation: spectral pointer is null");
return 0;
}
simctx = (struct spectralsim_context *)spectral->simctx;
qdf_assert_always(simctx);
if (!simctx) {
spectral_err("Spectral simulation: simctx pointer is null");
return 0;
}
return simctx->is_enabled;
}
@@ -727,10 +748,15 @@ target_if_spectral_sops_sim_start_scan(void *arg)
struct spectralsim_context *simctx = NULL;
spectral = (struct target_if_spectral *)arg;
qdf_assert_always(spectral);
if (!spectral) {
spectral_err("Spectral simulation: spectral pointer is null");
return 0;
}
simctx = (struct spectralsim_context *)spectral->simctx;
qdf_assert_always(simctx);
if (!simctx) {
spectral_err("Spectral simulation: simctx pointer is null");
return 0;
}
if (!simctx->curr_reportset) {
spectral_err("Spectral simulation: No current report set configured - unable to start simulated Spectral scan");
@@ -775,10 +801,15 @@ target_if_spectral_sops_sim_stop_scan(void *arg)
struct spectralsim_context *simctx = NULL;
spectral = (struct target_if_spectral *)arg;
qdf_assert_always(spectral);
if (!spectral) {
spectral_err("Spectral simulation: spectral pointer is null");
return 0;
}
simctx = (struct spectralsim_context *)spectral->simctx;
qdf_assert_always(simctx);
if (!simctx) {
spectral_err("Spectral simulation: simctx pointer is null");
return 0;
}
qdf_timer_stop(&simctx->ssim_pherrdelivery_timer);
@@ -852,16 +883,24 @@ target_if_spectral_sops_sim_configure_params(
uint8_t bw;
struct spectralsim_reportset *des_headreportset = NULL;
struct spectralsim_reportset *temp_reportset = NULL;
bool is_invalid_width = false;
struct wlan_objmgr_vdev *vdev = NULL;
qdf_assert_always(params);
if (!params) {
spectral_err("Spectral simulation: params pointer is null.")
return 0;
}
target_if_log_sim_spectral_params(params);
spectral = (struct target_if_spectral *)arg;
qdf_assert_always(spectral);
spectral = (struct target_if_spectral *)arg;
if (!spectral) {
spectral_err("Spectral simulation: spectral pointer is null");
return 0;
}
simctx = (struct spectralsim_context *)spectral->simctx;
qdf_assert_always(simctx);
if (!simctx) {
spectral_err("Spectral simulation: simctx pointer is null");
return 0;
}
vdev = target_if_spectral_get_vdev(spectral, smode);
if (!vdev) {
@@ -888,20 +927,15 @@ target_if_spectral_sops_sim_configure_params(
des_headreportset = simctx->bw80_80_headreportset;
break;
case CH_WIDTH_INVALID:
spectral_err("Spectral simulation: Invalid width configured - not proceeding with param config.");
is_invalid_width = true;
default:
spectral_err("Spectral simulation: Unknown width %u...asserting",
spectral_err("Spectral simulation: Invalid width: %d configured - not proceeding with param config.",
bw);
qdf_assert_always(0);
break;
wlan_objmgr_vdev_release_ref(vdev, WLAN_SPECTRAL_ID);
return 0;
}
wlan_objmgr_vdev_release_ref(vdev, WLAN_SPECTRAL_ID);
if (is_invalid_width)
return 0;
if (!des_headreportset) {
spectral_warn("Spectral simulation: No simulation data present for configured bandwidth/PHY mode - unable to proceed with param config.");
return 0;
@@ -941,14 +975,19 @@ target_if_spectral_sops_sim_get_params(
{
struct target_if_spectral *spectral = NULL;
struct spectralsim_context *simctx = NULL;
qdf_assert_always(params);
spectral = (struct target_if_spectral *)arg;
qdf_assert_always(spectral);
if (!param || !spectral) {
spectral_err("Spectral simulation: null params, param %pK, spectral %pK.",
param, spectral);
return 0;
}
simctx = (struct spectralsim_context *)spectral->simctx;
qdf_assert_always(simctx);
if (!simctx) {
spectral_err("Spectral simulation: simctx pointer is null.");
return 0;
}
if (!simctx->curr_reportset) {
spectral_warn("Spectral simulation: No configured reportset found.");