From 2a97de8792a0187f9590d5ec5bb1b818bac88890 Mon Sep 17 00:00:00 2001 From: Michal Mielewczyk Date: Wed, 5 Jul 2023 09:34:04 +0200 Subject: [PATCH] Detach finish: destroy stop pipeline before cmpl 'stop_pipeline' filed may be reused during cache lifetime (e.g. when cache is detached and attached again - the pipeline would be freed and then re-allocated). Calling completion after detach before freeing the pipeline may lead to race condition. 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 83ca25f..7da5964 100644 --- a/src/mngt/ocf_mngt_cache.c +++ b/src/mngt/ocf_mngt_cache.c @@ -3754,12 +3754,13 @@ static void ocf_mngt_cache_detach_finish(ocf_pipeline_t pipeline, "Detaching device failed\n"); } + ocf_pipeline_destroy(cache->stop_pipeline); + cache->stop_pipeline = NULL; + context->cmpl(cache, context->priv, error ?: context->cache_write_error); ocf_pipeline_destroy(context->pipeline); - ocf_pipeline_destroy(cache->stop_pipeline); - cache->stop_pipeline = NULL; } struct ocf_pipeline_properties ocf_mngt_cache_detach_pipeline_properties = {