From 20ad0478c850c9062ec7cc4eccb811d8087135bd Mon Sep 17 00:00:00 2001 From: Robert Baldyga Date: Mon, 2 Sep 2024 12:16:59 +0200 Subject: [PATCH] rpool: Mark an entry for kmemleak outside of atomic context The kmemleak_alloc() function can sleep, thus should not be called under spinlock. This patch fixes bug occurring on debug kernel with kmemleak enabled. Signed-off-by: Robert Baldyga --- modules/cas_cache/utils/utils_rpool.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/cas_cache/utils/utils_rpool.c b/modules/cas_cache/utils/utils_rpool.c index 94ef093f6..a7e058f16 100644 --- a/modules/cas_cache/utils/utils_rpool.c +++ b/modules/cas_cache/utils/utils_rpool.c @@ -218,12 +218,15 @@ void *cas_rpool_try_get(struct cas_reserve_pool *rpool_master, int *cpu) entry = RPOOL_ITEM_TO_ENTRY(rpool_master, item); list_del(item); atomic_dec(¤t_rpool->count); - /* The actuall allocation - kmemleak should start tracking page */ - kmemleak_alloc(entry, rpool_master->entry_size, 1, GFP_NOIO); } spin_unlock_irqrestore(¤t_rpool->lock, flags); + if (entry) { + /* The actual allocation - kmemleak should start tracking page */ + kmemleak_alloc(entry, rpool_master->entry_size, 1, GFP_NOIO); + } + CAS_DEBUG_PARAM("[%s]Removed item from reserve pool [%s] for cpu [%d], " "items in pool %d", rpool_master->name, item == NULL ? "SKIPPED" : "OK", *cpu,