From e373ea21638592dbb8c577ba09db7e734d5f40be Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Sat, 20 Jun 2026 02:10:10 +0300 Subject: [PATCH] Fix freeing of dyn_data and temp metadata block buffers on read cancel A regression test would also be fun --- src/blockstore/v1/read.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/blockstore/v1/read.cpp b/src/blockstore/v1/read.cpp index ea33974c..c2b96550 100644 --- a/src/blockstore/v1/read.cpp +++ b/src/blockstore/v1/read.cpp @@ -552,20 +552,17 @@ int blockstore_impl_t::dequeue_read(blockstore_op_t *read_op) undo_read: // need to wait. undo added requests, don't dequeue op release_clean(read_op); - if (dsk.csum_block_size > dsk.bitmap_granularity) + for (auto & vec: rv) { - for (auto & vec: rv) + if ((vec.copy_flags & COPY_BUF_CSUM_FILL) && vec.buf) { - if ((vec.copy_flags & COPY_BUF_CSUM_FILL) && vec.buf) - { - free(vec.buf); - vec.buf = NULL; - } - if (vec.dyn_data && --(*vec.dyn_data) == 0) // refcount - { - free(vec.dyn_data); - vec.dyn_data = NULL; - } + free(vec.buf); + vec.buf = NULL; + } + if (vec.dyn_data && --(*vec.dyn_data) == 0) // refcount + { + free(vec.dyn_data); + vec.dyn_data = NULL; } } rv.clear();