Protect core config preparation function against non-existing cache

It is legal to call KCAS_IOCTL_INSERT_CORE against non-existing cache
(in try_add mode), however in that case core_id has to be provded.
Return error code in case when given cache id does not exist and core_id
is set to OCF_CORE_MAX.

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
Robert Baldyga 2022-01-10 20:03:50 +01:00
parent 4333f5f62c
commit 05e0590fbc

View File

@ -1178,6 +1178,10 @@ int cache_mngt_prepare_core_cfg(struct ocf_mngt_core_config *cfg,
if (cmd_info->core_id == OCF_CORE_MAX) { if (cmd_info->core_id == OCF_CORE_MAX) {
struct cache_priv *cache_priv; struct cache_priv *cache_priv;
if (!cache)
return -OCF_ERR_CACHE_NOT_EXIST;
cache_priv = ocf_cache_get_priv(cache); cache_priv = ocf_cache_get_priv(cache);
core_id = find_free_core_id(cache_priv->core_id_bitmap); core_id = find_free_core_id(cache_priv->core_id_bitmap);
if (core_id == OCF_CORE_MAX) if (core_id == OCF_CORE_MAX)