Skip to content

Commit 2b27ea5

Browse files
bertoggrafaeljw
authored andcommitted
PM: hibernate: return -ENODATA if the snapshot image is not loaded
snapshot_image_loaded() is used in both the in-kernel and the userspace restore path to ensure that the snapshot image has been completely loaded. However the latter path returns -EPERM in such situations, which is meant for cases where the operation is neither write-only nor ready. This patch updates the check so the returned error code is -ENODATA in both cases. Suggested-by: Brian Geffon <bgeffon@google.com> Signed-off-by: Alberto Garcia <berto@igalia.com> Acked-by: Brian Geffon <bgeffon@google.com> Link: https://patch.msgid.link/8cfda38659c623f5392f3458cb32504ffd556a74.1773075892.git.berto@igalia.com Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 9b0f1cd commit 2b27ea5

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

kernel/power/user.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,11 +322,14 @@ static long snapshot_ioctl(struct file *filp, unsigned int cmd,
322322
error = snapshot_write_finalize(&data->handle);
323323
if (error)
324324
break;
325-
if (data->mode != O_WRONLY || !data->frozen ||
326-
!snapshot_image_loaded(&data->handle)) {
325+
if (data->mode != O_WRONLY || !data->frozen) {
327326
error = -EPERM;
328327
break;
329328
}
329+
if (!snapshot_image_loaded(&data->handle)) {
330+
error = -ENODATA;
331+
break;
332+
}
330333
error = hibernation_restore(data->platform_support);
331334
break;
332335

0 commit comments

Comments
 (0)