Check if cache is attached before setting promotion and seqcutoff params

Fixes null pointer dereference if setting those params is attempted
on detached cache.

Signed-off-by: Rafal Stefanowski <rafal.stefanowski@huawei.com>
This commit is contained in:
Rafal Stefanowski 2025-03-11 16:43:28 +01:00
parent a12496320c
commit 794fa125e8
2 changed files with 9 additions and 0 deletions

View File

@ -3733,6 +3733,9 @@ int ocf_mngt_cache_promotion_set_param(ocf_cache_t cache, ocf_promotion_t type,
if (ocf_cache_is_standby(cache))
return -OCF_ERR_CACHE_STANDBY;
if (!ocf_cache_is_device_attached(cache))
return -OCF_ERR_CACHE_DETACHED;
ocf_metadata_start_exclusive_access(&cache->metadata.lock);
result = ocf_promotion_set_param(cache, type, param_id, param_value);

View File

@ -1258,6 +1258,9 @@ int ocf_mngt_core_set_seq_cutoff_promote_on_threshold(ocf_core_t core,
if (ocf_cache_is_standby(cache))
return -OCF_ERR_CACHE_STANDBY;
if (!ocf_cache_is_device_attached(cache))
return -OCF_ERR_CACHE_DETACHED;
return _cache_mngt_set_core_seq_cutoff_promote_on_threshold(core, &promote);
}
@ -1269,6 +1272,9 @@ int ocf_mngt_core_set_seq_cutoff_promote_on_threshold_all(ocf_cache_t cache,
if (ocf_cache_is_standby(cache))
return -OCF_ERR_CACHE_STANDBY;
if (!ocf_cache_is_device_attached(cache))
return -OCF_ERR_CACHE_DETACHED;
return ocf_core_visit(cache,
_cache_mngt_set_core_seq_cutoff_promote_on_threshold,
&promote, true);