From cbee232e21b5f0016e1bf032bcdae2def75e173d Mon Sep 17 00:00:00 2001 From: Ananya Barat Date: Fri, 14 Feb 2020 13:55:43 +0530 Subject: [PATCH] qcacmn: Do not allocate memory of size zero In a few scenarios, the number of reg rules can be 0. For example, for a 2Ghz-only radio there are no 5Ghz reg rules. In such cases, if we try to allocate memory (0 bytes) the allocation function prints an error message. Also, the allocation is not required. Therefore, avoid the allocation when the number of rules is zero. Change-Id: Ic9caf578541970e9cf12cdde181f23762f137db8 CRs-Fixed: 2622109 --- wmi/src/wmi_unified_tlv.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/wmi/src/wmi_unified_tlv.c b/wmi/src/wmi_unified_tlv.c index c2f66f44ff..3174c6cdce 100644 --- a/wmi/src/wmi_unified_tlv.c +++ b/wmi/src/wmi_unified_tlv.c @@ -11194,7 +11194,11 @@ static struct cur_reg_rule struct cur_reg_rule *reg_rule_ptr; uint32_t count; - reg_rule_ptr = qdf_mem_malloc(num_reg_rules * sizeof(*reg_rule_ptr)); + if (!num_reg_rules) + return NULL; + + reg_rule_ptr = qdf_mem_malloc(num_reg_rules * + sizeof(*reg_rule_ptr)); if (!reg_rule_ptr) return NULL;