[PATCH] PM: hibernate: Restore PM notifiers on snapshot open failure

From: tuhaowen

Date: Thu Nov 12 2026 - 20:23:10 EST


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>
---
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