qcacmn: validate hw caps before dereferencing
Currently we are dereferencing hw caps without validation which
may cause kernel panic.
Add changes to validate hw caps before dereferencing.
Change-Id: I642dd4c0db872c4cf3bdff7e5fbccbacc82f307d
CRs-Fixed: 2049122
diff --git a/wmi_unified_tlv.c b/wmi_unified_tlv.c
index 1885af4..20602f7 100644
--- a/wmi_unified_tlv.c
+++ b/wmi_unified_tlv.c
@@ -16500,9 +16500,11 @@
else
param->num_phy = 0;
- param->num_chainmask_tables = hw_caps->num_chainmask_tables;
-
- qdf_print("Num chain mask tables: %d\n", hw_caps->num_chainmask_tables);
+ if (hw_caps) {
+ param->num_chainmask_tables = hw_caps->num_chainmask_tables;
+ qdf_print("Num chain mask tables: %d\n", hw_caps->num_chainmask_tables);
+ } else
+ param->num_chainmask_tables = 0;
chain_mask_combo = param_buf->mac_phy_chainmask_combo;
@@ -16511,7 +16513,7 @@
qdf_print("Dumping chain mask combo data\n");
- for (i = 0; i < hw_caps->num_chainmask_tables; i++) {
+ for (i = 0; i < param->num_chainmask_tables; i++) {
qdf_print("table_id : %d Num valid chainmasks: %d\n",
chain_mask_combo->chainmask_table_id,