aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/power/swap.c
diff options
context:
space:
mode:
authorJiri Slaby <jirislaby@gmail.com>2009-10-07 16:37:35 -0400
committerRafael J. Wysocki <rjw@sisk.pl>2009-11-03 05:01:46 -0500
commit76b57e613f6006ff525a17876c89326d127cadc9 (patch)
tree244d876f24581fb40d1900003c55b1c7ca5abb91 /kernel/power/swap.c
parent9905d1b411946fb3fb228e8c6529fd94afda8a92 (diff)
PM / Hibernate: Fix blkdev refleaks
While cruising through the swsusp code I found few blkdev reference leaks of resume_bdev. swsusp_read: remove blkdev_put altogether. Some fail paths do not do that. swsusp_check: make sure we always put a reference on fail paths software_resume: all fail paths between swsusp_check and swsusp_read omit swsusp_close. Add it in those cases. And since swsusp_read doesn't drop the reference anymore, do it here unconditionally. [rjw: Fixed a small coding style issue.] Signed-off-by: Jiri Slaby <jirislaby@gmail.com> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Diffstat (limited to 'kernel/power/swap.c')
-rw-r--r--kernel/power/swap.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/kernel/power/swap.c b/kernel/power/swap.c
index b101cdc4df3f..a4388624ed98 100644
--- a/kernel/power/swap.c
+++ b/kernel/power/swap.c
@@ -572,8 +572,6 @@ int swsusp_read(unsigned int *flags_p)
572 error = load_image(&handle, &snapshot, header->pages - 1); 572 error = load_image(&handle, &snapshot, header->pages - 1);
573 release_swap_reader(&handle); 573 release_swap_reader(&handle);
574 574
575 blkdev_put(resume_bdev, FMODE_READ);
576
577 if (!error) 575 if (!error)
578 pr_debug("PM: Image successfully loaded\n"); 576 pr_debug("PM: Image successfully loaded\n");
579 else 577 else
@@ -596,7 +594,7 @@ int swsusp_check(void)
596 error = bio_read_page(swsusp_resume_block, 594 error = bio_read_page(swsusp_resume_block,
597 swsusp_header, NULL); 595 swsusp_header, NULL);
598 if (error) 596 if (error)
599 return error; 597 goto put;
600 598
601 if (!memcmp(SWSUSP_SIG, swsusp_header->sig, 10)) { 599 if (!memcmp(SWSUSP_SIG, swsusp_header->sig, 10)) {
602 memcpy(swsusp_header->sig, swsusp_header->orig_sig, 10); 600 memcpy(swsusp_header->sig, swsusp_header->orig_sig, 10);
@@ -604,8 +602,10 @@ int swsusp_check(void)
604 error = bio_write_page(swsusp_resume_block, 602 error = bio_write_page(swsusp_resume_block,
605 swsusp_header, NULL); 603 swsusp_header, NULL);
606 } else { 604 } else {
607 return -EINVAL; 605 error = -EINVAL;
608 } 606 }
607
608put:
609 if (error) 609 if (error)
610 blkdev_put(resume_bdev, FMODE_READ); 610 blkdev_put(resume_bdev, FMODE_READ);
611 else 611 else