Skip to content

Commit 2f41ddd

Browse files
rjwysockiLinus Torvalds
authored andcommitted
swsusp: Fix userland interface
Fix oops caused by 'cat /dev/snapshot', reported by Arkadiusz Miskiewicz, and make it impossible to thaw tasks with the help of the swsusp userland interface while there is a snapshot image ready to save. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent b1d93de commit 2f41ddd

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎kernel/power/user.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ static ssize_t snapshot_read(struct file *filp, char __user *buf,
9999
ssize_t res;
100100

101101
data = filp->private_data;
102+
if (!data->ready)
103+
return -ENODATA;
102104
res = snapshot_read_next(&data->handle, count);
103105
if (res > 0) {
104106
if (copy_to_user(buf, data_of(data->handle), res))
@@ -245,7 +247,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
245247
break;
246248

247249
case SNAPSHOT_UNFREEZE:
248-
if (!data->frozen)
250+
if (!data->frozen || data->ready)
249251
break;
250252
mutex_lock(&pm_mutex);
251253
thaw_processes();

0 commit comments

Comments
 (0)