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 <michal.mielewczyk@huawei.com>
This commit is contained in:
Michal Mielewczyk 2023-07-05 09:34:04 +02:00 committed by Rafal Stefanowski
parent 283a897eeb
commit 2a97de8792

View File

@ -3754,12 +3754,13 @@ static void ocf_mngt_cache_detach_finish(ocf_pipeline_t pipeline,
"Detaching device failed\n"); "Detaching device failed\n");
} }
ocf_pipeline_destroy(cache->stop_pipeline);
cache->stop_pipeline = NULL;
context->cmpl(cache, context->priv, context->cmpl(cache, context->priv,
error ?: context->cache_write_error); error ?: context->cache_write_error);
ocf_pipeline_destroy(context->pipeline); 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 = { struct ocf_pipeline_properties ocf_mngt_cache_detach_pipeline_properties = {