Re: [PATCH v2] PM: hibernate: call preallocate_image after freeze prepare

From: Matthew Leach

Date: Wed Apr 01 2026 - 06:16:11 EST


Hi Rafael,

Thanks for the review.

"Rafael J. Wysocki" <rafael@xxxxxxxxxx> writes:

> On Thu, Mar 26, 2026 at 12:37 PM Matthew Leach
> <matthew.leach@xxxxxxxxxxxxx> wrote:

[...]

>> @@ -493,9 +465,9 @@ int hibernation_snapshot(int platform_mode)
>> return error;
>>
>> Thaw:
>
> swsusp_free() needs to be called here AFAICS or you'll see memory
> allocation failures subsequently in some cases.

We only jump to this label in two places:

- If dpm_prepare(PMSG_FREEZE) returns an error.
hibernate_preallocate_memory() hasn't been called yet so there's no
memory to free.

- If hibernate_preallocate_memory() returns an error; in that instance
hibernate_preallocate_memory() calls swsusp_free() to cleanup any
memory that may have been allocated before returning the error.

AFAICS, I don't think we need an extra call to swsusp_free(). Happy to
change if I'm missing something though.

Regards,
--
Matt