mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-31 14:04:27 -04:00
PM: hibernate: Fix memory leak in snapshot_write_next() error path
When memory_bm_create() succeeds for copy_bm but fails for zero_bm,
the function returns without freeing the resources allocated for
copy_bm. This results in a memory leak that includes radix tree nodes,
zone structures, and page lists.
Fix this by calling memory_bm_free() to release copy_bm's resources
before returning the error code when zero_bm allocation fails.
Fixes: 005e8dddd4 ("PM: hibernate: don't store zero pages in the image file")
Signed-off-by: Malaya Kumar Rout <malayarout91@gmail.com>
Acked-by: Brian Geffon <bgeffon@google.com>
Link: https://patch.msgid.link/20260711145246.8625-1-malayarout91@gmail.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:
committed by
Rafael J. Wysocki
parent
45a7c1077b
commit
21d5c4cee3
@@ -2797,9 +2797,10 @@ int snapshot_write_next(struct snapshot_handle *handle)
|
||||
return error;
|
||||
|
||||
error = memory_bm_create(&zero_bm, GFP_ATOMIC, PG_ANY);
|
||||
if (error)
|
||||
if (error) {
|
||||
memory_bm_free(©_bm, PG_UNSAFE_CLEAR);
|
||||
return error;
|
||||
|
||||
}
|
||||
nr_zero_pages = 0;
|
||||
|
||||
hibernate_restore_protection_begin();
|
||||
|
||||
Reference in New Issue
Block a user