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