From a2bef439755f4b542934475282279ad1f2875f70 Mon Sep 17 00:00:00 2001 From: Robert Baldyga Date: Fri, 6 Aug 2021 10:06:19 +0200 Subject: [PATCH] Add missing lock in ocf_ctx_get_volume_type_id() Signed-off-by: Robert Baldyga --- src/ocf_ctx.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ocf_ctx.c b/src/ocf_ctx.c index c50cb0a..6bbb97d 100644 --- a/src/ocf_ctx.c +++ b/src/ocf_ctx.c @@ -98,12 +98,14 @@ int ocf_ctx_get_volume_type_id(ocf_ctx_t ctx, ocf_volume_type_t type) OCF_CHECK_NULL(ctx); + env_rmutex_lock(&ctx->lock); for (i = 0; i < OCF_VOLUME_TYPE_MAX; ++i) { if (ctx->volume_type[i] == type) - return i; + break; } + env_rmutex_unlock(&ctx->lock); - return -1; + return (i < OCF_VOLUME_TYPE_MAX) ? i : -1; } /*