From 0a36379f50d98031de1ef2aef97a15c5351dfa57 Mon Sep 17 00:00:00 2001 From: Nicolae Vartolomei Date: Wed, 20 Nov 2024 00:49:40 +0000 Subject: [PATCH] cst/cache: fix use-after-move caused by calling get_exception twice Found by @dotnwat https://github.com/redpanda-data/redpanda/pull/24000#discussion_r1849302646 (cherry picked from commit ec90163a82d00cf0432a76a99e9ee45c7c394970) --- src/v/cloud_storage/cache_service.cc | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/v/cloud_storage/cache_service.cc b/src/v/cloud_storage/cache_service.cc index dc6b437a45780..3a4e8c1653726 100644 --- a/src/v/cloud_storage/cache_service.cc +++ b/src/v/cloud_storage/cache_service.cc @@ -1311,14 +1311,15 @@ ss::future<> cache::put( if (!_gate.is_closed()) { auto delete_tmp_fut = co_await ss::coroutine::as_future( delete_file_and_empty_parents(tmp_filepath.native())); - if ( - delete_tmp_fut.failed() - && !ssx::is_shutdown_exception(delete_tmp_fut.get_exception())) { - vlog( - cst_log.error, - "Failed to delete tmp file {}: {}", - tmp_filepath.native(), - delete_tmp_fut.get_exception()); + if (delete_tmp_fut.failed()) { + auto e = delete_tmp_fut.get_exception(); + if (!ssx::is_shutdown_exception(e)) { + vlog( + cst_log.error, + "Failed to delete tmp file {}: {}", + tmp_filepath.native(), + e); + } } }