cnss_prealloc: fix GFP flag for mempool_alloc

As per implementation of might_sleep(), rcu_read_lock()
nesting depth should be take into consideration too to
figure out whether sleeping is allowable or not.
To make align with it, allocate memory with GFP_ATOMIC
if rcu_read_lock() nesting depth is not zero.

Change-Id: Ib225a33b1a3f37b919e41daf064ce2de44428973
CRs-Fixed: 3271651
This commit is contained in:
Yu Wang
2022-08-18 10:12:38 -07:00
committed by Madan Koyyalamudi
parent 99c1335031
commit 728b08d683

View File

@@ -195,7 +195,8 @@ void *wcnss_prealloc_get(size_t size)
gfp_t gfp_mask = __GFP_ZERO; gfp_t gfp_mask = __GFP_ZERO;
int i; int i;
if (in_interrupt() || irqs_disabled()) if (in_interrupt() || irqs_disabled() ||
in_atomic() || rcu_preempt_depth())
gfp_mask |= GFP_ATOMIC; gfp_mask |= GFP_ATOMIC;
else else
gfp_mask |= GFP_KERNEL; gfp_mask |= GFP_KERNEL;