Skip to contentSkip to conversation

dm cache: fix missing return in invalidate_committed's error path

PATCH New Ming-Hung Tsai 1 participant 1 message Apr 10 Device mapper

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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")
---
 drivers/md/dm-cache-target.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/md/dm-cache-target.c +3 -1
index 51453f01a7ea..aca8b37ad5ce 100644
@@ -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);
Signature · 1 line
2.49.0