Don't access cache priv before locking cache

Cache priv may be freed by concurrent stop.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
This commit is contained in:
Michal Mielewczyk 2023-09-20 08:57:37 +02:00 committed by Robert Baldyga
parent 79a73fded2
commit 72594436ce

View File

@ -3199,10 +3199,6 @@ int cache_mngt_exit_instance(const char *cache_name, size_t name_len, int flush)
if (status)
return status;
cache_priv = ocf_cache_get_priv(cache);
mngt_queue = cache_priv->mngt_queue;
context = cache_priv->stop_context;
/*
* Flush cache. Flushing may take a long time, so we allow user
* to interrupt this operation. Hence we do first flush before
@ -3221,6 +3217,10 @@ int cache_mngt_exit_instance(const char *cache_name, size_t name_len, int flush)
if (status)
goto put;
cache_priv = ocf_cache_get_priv(cache);
mngt_queue = cache_priv->mngt_queue;
context = cache_priv->stop_context;
context->finish_thread = cas_lazy_thread_create(exit_instance_finish,
context, "cas_%s_stop", cache_name);
if (IS_ERR(context->finish_thread)) {