diff options
author | Shaohua Li <shaohua.li@intel.com> | 2005-09-03 18:57:04 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@evo.osdl.org> | 2005-09-05 03:06:17 -0400 |
commit | dd5d666b7995e542b7f81a4bb1c7ad634f4f6c51 (patch) | |
tree | de010e4bd66681ec75657746d652eb89f08142b7 /kernel/power/disk.c | |
parent | 6ed9fcec85d5ef0e34ea18affe95e4a246714565 (diff) |
[PATCH] swsusp: add locking to software_resume
It is trying to protect swsusp_resume_device and software_resume() from two
users banging it from userspace at the same time.
Signed-off-by: Shaohua Li <shaohua.li@intel.com>
Signed-off-by: Pavel Machek <pavel@suse.cz>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel/power/disk.c')
-rw-r--r-- | kernel/power/disk.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/kernel/power/disk.c b/kernel/power/disk.c index 664eb0469b6e..88beec6dcd11 100644 --- a/kernel/power/disk.c +++ b/kernel/power/disk.c | |||
@@ -233,9 +233,12 @@ static int software_resume(void) | |||
233 | { | 233 | { |
234 | int error; | 234 | int error; |
235 | 235 | ||
236 | down(&pm_sem); | ||
236 | if (!swsusp_resume_device) { | 237 | if (!swsusp_resume_device) { |
237 | if (!strlen(resume_file)) | 238 | if (!strlen(resume_file)) { |
239 | up(&pm_sem); | ||
238 | return -ENOENT; | 240 | return -ENOENT; |
241 | } | ||
239 | swsusp_resume_device = name_to_dev_t(resume_file); | 242 | swsusp_resume_device = name_to_dev_t(resume_file); |
240 | pr_debug("swsusp: Resume From Partition %s\n", resume_file); | 243 | pr_debug("swsusp: Resume From Partition %s\n", resume_file); |
241 | } else { | 244 | } else { |
@@ -248,6 +251,7 @@ static int software_resume(void) | |||
248 | * FIXME: If noresume is specified, we need to find the partition | 251 | * FIXME: If noresume is specified, we need to find the partition |
249 | * and reset it back to normal swap space. | 252 | * and reset it back to normal swap space. |
250 | */ | 253 | */ |
254 | up(&pm_sem); | ||
251 | return 0; | 255 | return 0; |
252 | } | 256 | } |
253 | 257 | ||
@@ -284,6 +288,8 @@ static int software_resume(void) | |||
284 | Cleanup: | 288 | Cleanup: |
285 | unprepare_processes(); | 289 | unprepare_processes(); |
286 | Done: | 290 | Done: |
291 | /* For success case, the suspend path will release the lock */ | ||
292 | up(&pm_sem); | ||
287 | pr_debug("PM: Resume from disk failed.\n"); | 293 | pr_debug("PM: Resume from disk failed.\n"); |
288 | return 0; | 294 | return 0; |
289 | } | 295 | } |
@@ -390,7 +396,9 @@ static ssize_t resume_store(struct subsystem * subsys, const char * buf, size_t | |||
390 | if (sscanf(buf, "%u:%u", &maj, &min) == 2) { | 396 | if (sscanf(buf, "%u:%u", &maj, &min) == 2) { |
391 | res = MKDEV(maj,min); | 397 | res = MKDEV(maj,min); |
392 | if (maj == MAJOR(res) && min == MINOR(res)) { | 398 | if (maj == MAJOR(res) && min == MINOR(res)) { |
399 | down(&pm_sem); | ||
393 | swsusp_resume_device = res; | 400 | swsusp_resume_device = res; |
401 | up(&pm_sem); | ||
394 | printk("Attempting manual resume\n"); | 402 | printk("Attempting manual resume\n"); |
395 | noresume = 0; | 403 | noresume = 0; |
396 | software_resume(); | 404 | software_resume(); |