Re: [PATCH] PM: hibernate: Restore PM notifiers on snapshot open failure
From: Rafael J. Wysocki (Intel)
Date: Fri Nov 20 2026 - 11:41:56 EST
On Fri, Nov 13, 2026 at 2:01 AM tuhaowen <tuhaowen@xxxxxxxxxxxxx> wrote:
>
> Opening /dev/snapshot for writing calls the PM_RESTORE_PREPARE
> notifiers before allocating the basic memory bitmaps. If the allocation
> fails, snapshot_open() returns an error without sending PM_POST_RESTORE.
> The release callback is not called after a failed open, so it cannot undo
> the preparation either.
>
> In particular, the firmware loader enables firmware caching during
> PM_RESTORE_PREPARE and relies on PM_POST_RESTORE to reset the cache state
> and schedule the cached firmware for release. An allocation failure can
> therefore leave firmware caching enabled after the restore attempt has
> already failed.
>
> The robust notifier call only rolls back failures within the notifier
> chain. It does not cover a subsequent failure to allocate the bitmaps.
> Send PM_POST_RESTORE for that failure, after a successful prepare call,
> so that the notifiers can undo their preparation without being called
> twice when the prepare notification itself fails.
>
> Fixes: 70d932985757 ("notifier: Fix broken error handling pattern")
> Signed-off-by: tuhaowen <tuhaowen@xxxxxxxxxxxxx>
Can you please put your full name into the From: header and the
Signed-off-by: tag?
Failing to do so causes Sashiko to complain unnecessarily:
https://sashiko.dev/#/patchset/10852BF0B4974597%2B20261113010134.1408010-1-tuhaowen%40uniontech.com
> ---
> kernel/power/user.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/kernel/power/user.c b/kernel/power/user.c
> index 6e4f40e49319..e7e8016a4f1a 100644
> --- a/kernel/power/user.c
> +++ b/kernel/power/user.c
> @@ -87,6 +87,8 @@ static int snapshot_open(struct inode *inode, struct file *filp)
> error = pm_notifier_call_chain_robust(PM_RESTORE_PREPARE, PM_POST_RESTORE);
> if (!error) {
> error = create_basic_memory_bitmaps();
> + if (error)
> + pm_notifier_call_chain(PM_POST_RESTORE);
> data->free_bitmaps = !error;
> }
> }
> --
> 2.50.1
>