summaryrefslogtreecommitdiff
path: root/kernel/power/user.c
diff options
context:
space:
mode:
authorChristophe Leroy <christophe.leroy@csgroup.eu>2024-02-18 09:40:58 +0100
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2024-02-22 20:08:03 +0100
commitf4311756a83fb01c28a9bf841cbb7eb2b318eebf (patch)
tree3d8713631aeb8c1a5848ac3078cdb3a14fa97811 /kernel/power/user.c
parent3fec6e5961b77af6a952b77f5c2ea26f7513b216 (diff)
PM: hibernate: Don't ignore return from set_memory_ro()
set_memory_ro() and set_memory_rw() can fail, leaving memory unprotected. Take the returned value into account and abort in case of failure. Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> Reviewed-by: Kees Cook <keescook@chromium.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'kernel/power/user.c')
-rw-r--r--kernel/power/user.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/kernel/power/user.c b/kernel/power/user.c
index 3a4e70366f35..3aa41ba22129 100644
--- a/kernel/power/user.c
+++ b/kernel/power/user.c
@@ -317,7 +317,9 @@ static long snapshot_ioctl(struct file *filp, unsigned int cmd,
break;
case SNAPSHOT_ATOMIC_RESTORE:
- snapshot_write_finalize(&data->handle);
+ error = snapshot_write_finalize(&data->handle);
+ if (error)
+ break;
if (data->mode != O_WRONLY || !data->frozen ||
!snapshot_image_loaded(&data->handle)) {
error = -EPERM;