From 2f2f004867307b30a316503d3581caba6d126cc1 Mon Sep 17 00:00:00 2001 From: Vitaliy Mysak Date: Tue, 26 Mar 2019 19:07:22 +0000 Subject: [PATCH] Put cache after doing pipeline_destroy Cache is used during pipeline_destroy which means that doing put_cache before destroying pipeline may result in accessing memory that was freed. Signed-off-by: Vitaliy Mysak --- src/mngt/ocf_mngt_cache.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mngt/ocf_mngt_cache.c b/src/mngt/ocf_mngt_cache.c index ba62bfe..215fee1 100644 --- a/src/mngt/ocf_mngt_cache.c +++ b/src/mngt/ocf_mngt_cache.c @@ -2068,11 +2068,8 @@ static void ocf_mngt_cache_stop_finish(ocf_pipeline_t pipeline, cache->valid_ocf_cache_device_t = 0; /* Remove cache from the list */ list_del(&cache->list); - /* Finally release cache instance */ - ocf_mngt_cache_put(cache); env_mutex_unlock(&ctx->lock); - if (context->error == -OCF_ERR_WRITE_CACHE) { ocf_log(ctx, log_warn, "Stopped cache %s with errors\n", context->cache_name); @@ -2087,6 +2084,9 @@ static void ocf_mngt_cache_stop_finish(ocf_pipeline_t pipeline, context->cmpl(cache, context->priv, context->error); ocf_pipeline_destroy(context->pipeline); + + /* Finally release cache instance */ + ocf_mngt_cache_put(cache); } struct ocf_pipeline_properties ocf_mngt_cache_stop_pipeline_properties = {