summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMing-Hung Tsai <mtsai@redhat.com>2026-04-10 16:08:01 +0300
committerMikulas Patocka <mpatocka@redhat.com>2026-04-10 16:16:06 +0300
commit8c0ee19db81f0fa1ff25fd75b22b17c0cc2acde3 (patch)
tree5e7f28af28d0a4164e0f1c2706b5bfe6f006baf8
parent2fa49cc884f6496a915c35621ba4da35649bf159 (diff)
downloadlinux-8c0ee19db81f0fa1ff25fd75b22b17c0cc2acde3.tar.xz
dm cache: fix missing return in invalidate_committed's error path
In passthrough mode, dm-cache defers write submission until after metadata commit completes via the invalidate_committed() continuation. On commit error, invalidate_committed() calls invalidate_complete() to end the bio and free the migration struct, after which it should return immediately. The patch 4ca8b8bd952d ("dm cache: fix write hang in passthrough mode") omitted this early return, causing execution to fall through into the success path on error. This results in use-after-free on the migration struct in the subsequent calls. Fix by adding the missing return after the invalidate_complete() call. Fixes: 4ca8b8bd952d ("dm cache: fix write hang in passthrough mode") Reported-by: Dan Carpenter <error27@gmail.com> Closes: https://lore.kernel.org/dm-devel/adjMq6T5RRjv_uxM@stanley.mountain/ Signed-off-by: Ming-Hung Tsai <mtsai@redhat.com> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
-rw-r--r--drivers/md/dm-cache-target.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/md/dm-cache-target.c b/drivers/md/dm-cache-target.c
index f8200c154805..097315a9bf0f 100644
--- a/drivers/md/dm-cache-target.c
+++ b/drivers/md/dm-cache-target.c
@@ -1521,8 +1521,10 @@ static void invalidate_committed(struct work_struct *ws)
struct bio *bio = mg->overwrite_bio;
struct per_bio_data *pb = get_per_bio_data(bio);
- if (mg->k.input)
+ if (mg->k.input) {
invalidate_complete(mg, false);
+ return;
+ }
init_continuation(&mg->k, invalidate_completed);
remap_to_origin_clear_discard(cache, bio, mg->invalidate_oblock);