Commit 2f41dddb authored by Rafael J. Wysocki's avatar Rafael J. Wysocki Committed by Linus Torvalds

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: default avatarRafael J. Wysocki <rjw@sisk.pl>
Acked-by: default avatarPavel Machek <pavel@ucw.cz>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent b1d93de3
...@@ -99,6 +99,8 @@ static ssize_t snapshot_read(struct file *filp, char __user *buf, ...@@ -99,6 +99,8 @@ static ssize_t snapshot_read(struct file *filp, char __user *buf,
ssize_t res; ssize_t res;
data = filp->private_data; data = filp->private_data;
if (!data->ready)
return -ENODATA;
res = snapshot_read_next(&data->handle, count); res = snapshot_read_next(&data->handle, count);
if (res > 0) { if (res > 0) {
if (copy_to_user(buf, data_of(data->handle), res)) if (copy_to_user(buf, data_of(data->handle), res))
...@@ -245,7 +247,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp, ...@@ -245,7 +247,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
break; break;
case SNAPSHOT_UNFREEZE: case SNAPSHOT_UNFREEZE:
if (!data->frozen) if (!data->frozen || data->ready)
break; break;
mutex_lock(&pm_mutex); mutex_lock(&pm_mutex);
thaw_processes(); thaw_processes();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment