Commit 62b9ca17 authored by Mario Limonciello (AMD)'s avatar Mario Limonciello (AMD) Committed by Rafael J. Wysocki
Browse files

PM: hibernate: Emit an error when image writing fails



If image writing fails, a return code is passed up to the caller, but
none of the callers log anything to the log and so the only record
of it is the return code that userspace gets.

Adjust the logging so that the image size and speed of writing is
only emitted on success and if there is an error, it's saved to the
logs.

Fixes: a06c6f5d ("PM: hibernate: Move to crypto APIs for LZO compression")
Reported-by: default avatarAskar Safin <safinaskar@gmail.com>
Closes: https://lore.kernel.org/linux-pm/20251105180506.137448-1-safinaskar@gmail.com/


Signed-off-by: default avatarMario Limonciello (AMD) <superm1@kernel.org>
Tested-by: default avatarAskar Safin <safinaskar@gmail.com>
Cc: 6.9+ <stable@vger.kernel.org> # 6.9+
[ rjw: Added missing braces after "else", changelog edits ]
Link: https://patch.msgid.link/20251106045158.3198061-2-superm1@kernel.org


Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 6146a0f1
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -877,11 +877,14 @@ static int save_compressed_image(struct swap_map_handle *handle,
	stop = ktime_get();
	if (!ret)
		ret = err2;
	if (!ret)
		pr_info("Image saving done\n");
	if (!ret) {
		swsusp_show_speed(start, stop, nr_to_write, "Wrote");
		pr_info("Image size after compression: %d kbytes\n",
			(atomic_read(&compressed_size) / 1024));
		pr_info("Image saving done\n");
	} else {
		pr_err("Image saving failed: %d\n", ret);
	}

out_clean:
	hib_finish_batch(&hb);