Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

PM: hibernate: Use atomic64_t for compressed_size variable

`compressed_size` can overflow, showing nonsensical values.

Change from `atomic_t` to `atomic64_t` to prevent overflow.

Fixes: a06c6f5d3cc9 ("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>

authored by

Mario Limonciello (AMD) and committed by
Rafael J. Wysocki
66ededc6 62b9ca17

+5 -5
+5 -5
kernel/power/swap.c
··· 635 635 }; 636 636 637 637 /* Indicates the image size after compression */ 638 - static atomic_t compressed_size = ATOMIC_INIT(0); 638 + static atomic64_t compressed_size = ATOMIC_INIT(0); 639 639 640 640 /* 641 641 * Compression function that runs in its own thread. ··· 664 664 d->ret = crypto_acomp_compress(d->cr); 665 665 d->cmp_len = d->cr->dlen; 666 666 667 - atomic_set(&compressed_size, atomic_read(&compressed_size) + d->cmp_len); 667 + atomic64_add(d->cmp_len, &compressed_size); 668 668 atomic_set_release(&d->stop, 1); 669 669 wake_up(&d->done); 670 670 } ··· 696 696 697 697 hib_init_batch(&hb); 698 698 699 - atomic_set(&compressed_size, 0); 699 + atomic64_set(&compressed_size, 0); 700 700 701 701 /* 702 702 * We'll limit the number of threads for compression to limit memory ··· 879 879 ret = err2; 880 880 if (!ret) { 881 881 swsusp_show_speed(start, stop, nr_to_write, "Wrote"); 882 - pr_info("Image size after compression: %d kbytes\n", 883 - (atomic_read(&compressed_size) / 1024)); 882 + pr_info("Image size after compression: %lld kbytes\n", 883 + (atomic64_read(&compressed_size) / 1024)); 884 884 pr_info("Image saving done\n"); 885 885 } else { 886 886 pr_err("Image saving failed: %d\n", ret);