Эх сурвалжийг харах

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
Ananya Barat 5 жил өмнө
parent
commit
cbee232e21

+ 5 - 1
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;