From 84aa96887781800f10ac78c0ef715f6505788072 Mon Sep 17 00:00:00 2001 From: Robert Baldyga Date: Mon, 28 Mar 2022 22:08:05 +0200 Subject: [PATCH] Check for load error before accessing metadata content Signed-off-by: Robert Baldyga --- src/mngt/ocf_mngt_cache.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/mngt/ocf_mngt_cache.c b/src/mngt/ocf_mngt_cache.c index f1773b3..39a335d 100644 --- a/src/mngt/ocf_mngt_cache.c +++ b/src/mngt/ocf_mngt_cache.c @@ -1544,6 +1544,13 @@ static void _ocf_mngt_load_superblock_complete(void *priv, int error) ocf_cache_t cache = context->cache; ocf_cleaning_t loaded_clean_policy = cache->conf_meta->cleaning_policy_type; + if (error) { + ocf_cache_log(cache, log_err, + "ERROR: Cannot load cache state\n"); + OCF_PL_FINISH_RET(context->pipeline, + -OCF_ERR_START_CACHE_FAIL); + } + if (cache->conf_meta->cachelines != ocf_metadata_get_cachelines_count(cache)) { ocf_cache_log(cache, log_err, @@ -1561,13 +1568,6 @@ static void _ocf_mngt_load_superblock_complete(void *priv, int error) __set_cleaning_policy(cache, loaded_clean_policy); - if (error) { - ocf_cache_log(cache, log_err, - "ERROR: Cannot load cache state\n"); - OCF_PL_FINISH_RET(context->pipeline, - -OCF_ERR_START_CACHE_FAIL); - } - ocf_pipeline_next(context->pipeline); }