[PATCH v3 3/4] PM: hibernate: drain pending reads in compressed image load errors
From: Xiong Xin
Date: Thu Oct 01 2026 - 23:42:48 EST
The error exits of load_compressed_image() free the ring buffer pages
without waiting for the read bios that may still be in flight: when a
read or decompression error aborts the load mid-round, the device can
still be writing into pages that are handed back to the allocator by
out_clean().
save_compressed_image() and load_image() both drain the batch on their
way out; add the same wait here, which also folds the error of any
in-flight read into the return value instead of dropping it.
Fixes: 343df3c79c62 ("suspend: simplify block I/O handling")
Assisted-by: GLM:glm-5.3
Signed-off-by: Xiong Xin <xiongxin@xxxxxxxxxx>
---
New in v3: the compressed loader had the same missing drain on its
error exits, freeing the ring pages under in-flight reads.
kernel/power/swap.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/kernel/power/swap.c b/kernel/power/swap.c
index 7f3cc2cc5cca..571aefaf09f4 100644
--- a/kernel/power/swap.c
+++ b/kernel/power/swap.c
@@ -1204,6 +1204,7 @@ static int load_compressed_image(struct swap_map_handle *handle,
int ret = 0;
int eof = 0;
struct hib_bio_batch hb;
+ int err2;
ktime_t start;
ktime_t stop;
unsigned nr_pages;
@@ -1482,11 +1483,14 @@ static int load_compressed_image(struct swap_map_handle *handle,
}
out_finish:
+ err2 = hib_wait_io(&hb);
if (crc->run_threads) {
wait_event(crc->done, atomic_read_acquire(&crc->stop));
atomic_set(&crc->stop, 0);
}
stop = ktime_get();
+ if (!ret)
+ ret = err2;
if (!ret) {
pr_info("Image loading done\n");
ret = snapshot_write_finalize(snapshot);
--
2.25.1