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>

authored by Rafael J. Wysocki and committed by Linus Torvalds 2f41dddb b1d93de3

+3 -1
+3 -1
kernel/power/user.c
··· 99 99 ssize_t res; 100 100 101 101 data = filp->private_data; 102 + if (!data->ready) 103 + return -ENODATA; 102 104 res = snapshot_read_next(&data->handle, count); 103 105 if (res > 0) { 104 106 if (copy_to_user(buf, data_of(data->handle), res)) ··· 247 245 break; 248 246 249 247 case SNAPSHOT_UNFREEZE: 250 - if (!data->frozen) 248 + if (!data->frozen || data->ready) 251 249 break; 252 250 mutex_lock(&pm_mutex); 253 251 thaw_processes();