Commit 2b27ea5b authored by Alberto Garcia's avatar Alberto Garcia Committed by Rafael J. Wysocki
Browse files

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: default avatarBrian Geffon <bgeffon@google.com>
Signed-off-by: default avatarAlberto Garcia <berto@igalia.com>
Acked-by: default avatarBrian Geffon <bgeffon@google.com>
Link: https://patch.msgid.link/8cfda38659c623f5392f3458cb32504ffd556a74.1773075892.git.berto@igalia.com


Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 9b0f1cd5
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -322,11 +322,14 @@ static long snapshot_ioctl(struct file *filp, unsigned int cmd,
		error = snapshot_write_finalize(&data->handle);
		if (error)
			break;
		if (data->mode != O_WRONLY || !data->frozen ||
		    !snapshot_image_loaded(&data->handle)) {
		if (data->mode != O_WRONLY || !data->frozen) {
			error = -EPERM;
			break;
		}
		if (!snapshot_image_loaded(&data->handle)) {
			error = -ENODATA;
			break;
		}
		error = hibernation_restore(data->platform_support);
		break;