msm: ipa: Add Null checks in APIs in WDI driver

Added null check before accessing member variable in interface
APIs in WDI to avoid possible null pointer dereferencing

Change-Id: I862e4f137ce4a25357c20ff2ff26c761f7f3b156
Signed-off-by: Chaitanya Pratapa <quic_cpratapa@quicinc.com>
このコミットが含まれているのは:
Arjun Haris
2023-03-06 17:27:34 +05:30
コミット 3ca1c81311

ファイルの表示

@@ -813,6 +813,11 @@ int ipa_wdi_set_perf_profile_per_inst(ipa_wdi_hdl_t hdl,
return -EFAULT;
}
if (!ipa_wdi_ctx_list[hdl]) {
IPA_WDI_ERR("wdi ctx is not initialized.\n");
return -EPERM;
}
if (ipa_wdi_ctx_list[hdl]->wdi_version >= IPA_WDI_1 &&
ipa_wdi_ctx_list[hdl]->wdi_version < IPA_WDI_3 &&
hdl > 0) {
@@ -863,6 +868,11 @@ int ipa_wdi_create_smmu_mapping_per_inst(ipa_wdi_hdl_t hdl,
return -EFAULT;
}
if (!ipa_wdi_ctx_list[hdl]) {
IPA_WDI_ERR("wdi ctx is not initialized.\n");
return -EPERM;
}
if (IPA_CLIENT_IS_WLAN0_INSTANCE(ipa_wdi_ctx_list[hdl]->inst_id))
cb = ipa3_get_smmu_ctx(IPA_SMMU_CB_WLAN);
else
@@ -923,6 +933,11 @@ int ipa_wdi_release_smmu_mapping_per_inst(ipa_wdi_hdl_t hdl,
return -EFAULT;
}
if (!ipa_wdi_ctx_list[hdl]) {
IPA_WDI_ERR("wdi ctx is not initialized.\n");
return -EPERM;
}
if (IPA_CLIENT_IS_WLAN0_INSTANCE(ipa_wdi_ctx_list[hdl]->inst_id))
cb = ipa3_get_smmu_ctx(IPA_SMMU_CB_WLAN);
else
@@ -964,6 +979,11 @@ int ipa_wdi_cleanup_per_inst(ipa_wdi_hdl_t hdl)
return -EFAULT;
}
if (!ipa_wdi_ctx_list[hdl]) {
IPA_WDI_ERR("wdi ctx is not initialized.\n");
return -EPERM;
}
if (ipa_wdi_ctx_list[hdl]->wdi_version >= IPA_WDI_1 &&
ipa_wdi_ctx_list[hdl]->wdi_version < IPA_WDI_3 &&
hdl > 0) {
@@ -1007,6 +1027,12 @@ int ipa_wdi_dereg_intf_per_inst(const char *netdev_name,ipa_wdi_hdl_t hdl)
return -EFAULT;
}
if (!ipa_wdi_ctx_list[hdl]) {
IPA_WDI_ERR("wdi ctx is not initialized.\n");
return -EPERM;
}
if (ipa_wdi_ctx_list[hdl]->wdi_version >= IPA_WDI_1 &&
ipa_wdi_ctx_list[hdl]->wdi_version < IPA_WDI_3 &&
hdl > 0) {
@@ -1083,6 +1109,12 @@ int ipa_wdi_disconn_pipes_per_inst(ipa_wdi_hdl_t hdl)
return -EFAULT;
}
if (!ipa_wdi_ctx_list[hdl]) {
IPA_WDI_ERR("wdi ctx is not initialized.\n");
return -EPERM;
}
if (ipa_wdi_ctx_list[hdl]->wdi_version >= IPA_WDI_1 &&
ipa_wdi_ctx_list[hdl]->wdi_version < IPA_WDI_3 &&
hdl > 0) {
@@ -1091,10 +1123,6 @@ int ipa_wdi_disconn_pipes_per_inst(ipa_wdi_hdl_t hdl)
return -EPERM;
}
if (!ipa_wdi_ctx_list[hdl]) {
IPA_WDI_ERR("wdi ctx is not initialized\n");
return -EPERM;
}
IPA_WDI_DBG("Disconnect pipes for hdl %d\n",hdl);
/* tear down sys pipe if needed */
for (i = 0; i < ipa_wdi_ctx_list[hdl]->num_sys_pipe_needed; i++) {
@@ -1167,6 +1195,11 @@ int ipa_wdi_disable_pipes_per_inst(ipa_wdi_hdl_t hdl)
return -EFAULT;
}
if (!ipa_wdi_ctx_list[hdl]) {
IPA_WDI_ERR("wdi ctx is not initialized.\n");
return -EPERM;
}
if (ipa_wdi_ctx_list[hdl]->wdi_version >= IPA_WDI_1 &&
ipa_wdi_ctx_list[hdl]->wdi_version < IPA_WDI_3 &&
hdl > 0) {
@@ -1175,11 +1208,6 @@ int ipa_wdi_disable_pipes_per_inst(ipa_wdi_hdl_t hdl)
return -EPERM;
}
if (!ipa_wdi_ctx_list[hdl]) {
IPA_WDI_ERR("wdi ctx is not initialized.\n");
return -EPERM;
}
if (ipa_wdi_ctx_list[hdl]->wdi_version >= IPA_WDI_3) {
if (IPA_CLIENT_IS_WLAN0_INSTANCE(ipa_wdi_ctx_list[hdl]->inst_id)) {
ipa_ep_idx_rx = ipa_get_ep_mapping(IPA_CLIENT_WLAN2_PROD);