mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 01:49:46 +00:00
PM: hibernate: Use atomic64_t for compressed_size variable
commit66ededc694upstream. `compressed_size` can overflow, showing nonsensical values. Change from `atomic_t` to `atomic64_t` to prevent overflow. Fixes:a06c6f5d3c("PM: hibernate: Move to crypto APIs for LZO compression") Reported-by: Askar Safin <safinaskar@gmail.com> Closes: https://lore.kernel.org/linux-pm/20251105180506.137448-1-safinaskar@gmail.com/ Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org> Tested-by: Askar Safin <safinaskar@gmail.com> Cc: 6.9+ <stable@vger.kernel.org> # 6.9+ Link: https://patch.msgid.link/20251106045158.3198061-3-superm1@kernel.org Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
692101646f
commit
ee80ff1f10
@@ -635,7 +635,7 @@ struct cmp_data {
|
||||
};
|
||||
|
||||
/* Indicates the image size after compression */
|
||||
static atomic_t compressed_size = ATOMIC_INIT(0);
|
||||
static atomic64_t compressed_size = ATOMIC_INIT(0);
|
||||
|
||||
/*
|
||||
* Compression function that runs in its own thread.
|
||||
@@ -664,7 +664,7 @@ static int compress_threadfn(void *data)
|
||||
d->ret = crypto_acomp_compress(d->cr);
|
||||
d->cmp_len = d->cr->dlen;
|
||||
|
||||
atomic_set(&compressed_size, atomic_read(&compressed_size) + d->cmp_len);
|
||||
atomic64_add(d->cmp_len, &compressed_size);
|
||||
atomic_set_release(&d->stop, 1);
|
||||
wake_up(&d->done);
|
||||
}
|
||||
@@ -696,7 +696,7 @@ static int save_compressed_image(struct swap_map_handle *handle,
|
||||
|
||||
hib_init_batch(&hb);
|
||||
|
||||
atomic_set(&compressed_size, 0);
|
||||
atomic64_set(&compressed_size, 0);
|
||||
|
||||
/*
|
||||
* We'll limit the number of threads for compression to limit memory
|
||||
@@ -879,8 +879,8 @@ out_finish:
|
||||
ret = err2;
|
||||
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 size after compression: %lld kbytes\n",
|
||||
(atomic64_read(&compressed_size) / 1024));
|
||||
pr_info("Image saving done\n");
|
||||
} else {
|
||||
pr_err("Image saving failed: %d\n", ret);
|
||||
|
||||
Reference in New Issue
Block a user