From 244712b0206584a1d24267cc41f917efee1a731c Mon Sep 17 00:00:00 2001 From: Michal Mielewczyk Date: Tue, 7 Dec 2021 11:06:57 +0100 Subject: [PATCH] Prevent race condition in fast path Request submitted in fast path may be freed before the sequential cutoff stats are updated. Increment request reference counter to prevent it. Signed-off-by: Michal Mielewczyk --- src/ocf_core.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ocf_core.c b/src/ocf_core.c index 0c327f6..a1fcc54 100644 --- a/src/ocf_core.c +++ b/src/ocf_core.c @@ -302,12 +302,16 @@ void ocf_core_volume_submit_io(struct ocf_io *io) ocf_core_update_stats(core, io); ocf_io_get(io); + /* Prevent race condition */ + ocf_req_get(req); if (!ocf_core_submit_io_fast(io, req, core, cache)) { ocf_core_seq_cutoff_update(core, req); + ocf_req_put(req); return; } + ocf_req_put(req); ocf_req_clear_map(req); ocf_core_seq_cutoff_update(core, req);