msm: ipa3: add change to check log_type_mask defined or not
Adding a change to check whether log_type_mask is defined or
not to avoid allocating unknown memory size and to avoid out
of bound access.
Change-Id: I901863ee68f8c77424c4d4d3bb5f3a380a61dbee
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_stats.c b/drivers/platform/msm/ipa/ipa_v3/ipa_stats.c
index 085e1a3..c2b17c7 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipa_stats.c
+++ b/drivers/platform/msm/ipa/ipa_v3/ipa_stats.c
@@ -2,7 +2,7 @@
/*
* Copyright (c) 2021, The Linux Foundation. All rights reserved.
*
- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#include <linux/init.h>
@@ -138,6 +138,11 @@
struct holb_discard_stats *holb_disc_stats_ptr;
struct holb_monitor_stats *holb_mon_stats_ptr;
+ if(ipa_lnx_agent_ctx.log_type_mask == 0) {
+ IPA_STATS_ERR("log_type_mask is not defined");
+ return -EPERM;
+ }
+
alloc_size = sizeof(struct ipa_lnx_generic_stats) +
(sizeof(struct holb_discard_stats) *
ipa_lnx_agent_ctx.alloc_info.num_holb_drop_stats_clients) +
@@ -293,6 +298,11 @@
int alloc_size;
struct pm_client_stats *pm_stats_ptr;
+ if(ipa_lnx_agent_ctx.log_type_mask == 0) {
+ IPA_STATS_ERR("log_type_mask is not defined");
+ return -EPERM;
+ }
+
alloc_size = sizeof(struct ipa_lnx_clock_stats) +
(sizeof(struct pm_client_stats) *
ipa_lnx_agent_ctx.alloc_info.num_pm_clients);
@@ -605,6 +615,11 @@
struct wlan_instance_info *instance_ptr = NULL;
struct ipa_uc_dbg_ring_stats stats;
+ if(ipa_lnx_agent_ctx.log_type_mask == 0) {
+ IPA_STATS_ERR("log_type_mask is not defined");
+ return -EPERM;
+ }
+
alloc_size = sizeof(struct ipa_lnx_wlan_inst_stats) +
(ipa_lnx_agent_ctx.alloc_info.num_wlan_instances *
sizeof(struct wlan_instance_info));
@@ -785,6 +800,11 @@
struct eth_instance_info *instance_ptr = NULL;
struct ipa_uc_dbg_ring_stats stats;
+ if(ipa_lnx_agent_ctx.log_type_mask == 0) {
+ IPA_STATS_ERR("log_type_mask is not defined");
+ return -EPERM;
+ }
+
alloc_size = sizeof(struct ipa_lnx_eth_inst_stats) +
(ipa_lnx_agent_ctx.alloc_info.num_eth_instances *
sizeof(struct eth_instance_info));
@@ -1092,6 +1112,11 @@
struct usb_instance_info *instance_ptr = NULL;
struct ipa_uc_dbg_ring_stats stats;
+ if(ipa_lnx_agent_ctx.log_type_mask == 0) {
+ IPA_STATS_ERR("log_type_mask is not defined");
+ return -EPERM;
+ }
+
alloc_size = sizeof(struct ipa_lnx_usb_inst_stats) +
(ipa_lnx_agent_ctx.alloc_info.num_usb_instances *
sizeof(struct usb_instance_info));
@@ -1267,6 +1292,11 @@
struct mhip_instance_info *instance_ptr = NULL;
struct ipa_uc_dbg_ring_stats stats;
+ if(ipa_lnx_agent_ctx.log_type_mask == 0) {
+ IPA_STATS_ERR("log_type_mask is not defined");
+ return -EPERM;
+ }
+
alloc_size = sizeof(struct ipa_lnx_mhip_inst_stats) +
(ipa_lnx_agent_ctx.alloc_info.num_mhip_instances *
sizeof(struct mhip_instance_info));