Browse Source

cnss_prealloc: check cnss_pools before returning memory

Check cnss_pools before returning memory to wlan
host driver.

Change-Id: I44e2a34b3c232e08e7e1d4bdb567cd4de09f3eb1
CRs-Fixed: 3506939
Sandeep Singh 1 year ago
parent
commit
afc7a80790
1 changed files with 7 additions and 1 deletions
  1. 7 1
      cnss_prealloc/cnss_prealloc.c

+ 7 - 1
cnss_prealloc/cnss_prealloc.c

@@ -169,6 +169,9 @@ static void cnss_pool_deinit(void)
 {
 	int i;
 
+	if (!cnss_pools)
+		return;
+
 	for (i = 0; i < cnss_prealloc_pool_size; i++) {
 		pr_info("cnss_prealloc: destroy mempool %s\n",
 			cnss_pools[i].name);
@@ -298,6 +301,9 @@ void *wcnss_prealloc_get(size_t size)
 	gfp_t gfp_mask = __GFP_ZERO;
 	int i;
 
+	if (!cnss_pools)
+		return mem;
+
 	if (in_interrupt() || !preemptible() || rcu_preempt_depth())
 		gfp_mask |= GFP_ATOMIC;
 	else
@@ -337,7 +343,7 @@ int wcnss_prealloc_put(void *mem)
 {
 	int i;
 
-	if (!mem)
+	if (!mem || !cnss_pools)
 		return 0;
 
 	i = cnss_pool_get_index(mem);