Skip to content

Commit 8c0ee19

Browse files
mingnusMikulas Patocka
authored andcommitted
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 4ca8b8b ("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: 4ca8b8b ("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>
1 parent 2fa49cc commit 8c0ee19

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

drivers/md/dm-cache-target.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1521,8 +1521,10 @@ static void invalidate_committed(struct work_struct *ws)
15211521
struct bio *bio = mg->overwrite_bio;
15221522
struct per_bio_data *pb = get_per_bio_data(bio);
15231523

1524-
if (mg->k.input)
1524+
if (mg->k.input) {
15251525
invalidate_complete(mg, false);
1526+
return;
1527+
}
15261528

15271529
init_continuation(&mg->k, invalidate_completed);
15281530
remap_to_origin_clear_discard(cache, bio, mg->invalidate_oblock);

0 commit comments

Comments
 (0)