From 0bb2621c50d6181e3d1609e18f441f517ff2a3f1 Mon Sep 17 00:00:00 2001 From: Michal Mielewczyk Date: Mon, 7 Oct 2024 16:07:15 +0200 Subject: [PATCH] Increment ctx.refcnt before creating a new cache Signed-off-by: Michal Mielewczyk --- src/mngt/ocf_mngt_cache.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mngt/ocf_mngt_cache.c b/src/mngt/ocf_mngt_cache.c index 41cf698..b8798c9 100644 --- a/src/mngt/ocf_mngt_cache.c +++ b/src/mngt/ocf_mngt_cache.c @@ -1493,6 +1493,8 @@ static int _ocf_mngt_cache_start(ocf_ctx_t ctx, ocf_cache_t *cache, params.metadata.promotion_policy = cfg->promotion_policy; params.locked = cfg->locked; + ocf_ctx_get(ctx); + result = env_rmutex_lock_interruptible(&ctx->lock); if (result) goto _cache_mngt_init_instance_ERROR; @@ -1533,8 +1535,6 @@ static int _ocf_mngt_cache_start(ocf_ctx_t ctx, ocf_cache_t *cache, _ocf_mngt_cache_init(tmp_cache, ¶ms); - ocf_ctx_get(ctx); - if (!params.locked) { /* User did not request to lock cache instance after creation - unlock it here since we have acquired the lock to @@ -1550,6 +1550,7 @@ static int _ocf_mngt_cache_start(ocf_ctx_t ctx, ocf_cache_t *cache, _cache_mngt_init_instance_ERROR: _ocf_mngt_init_handle_error(ctx, ¶ms); *cache = NULL; + ocf_ctx_put(ctx); return result; }