aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerge E. Hallyn <serue@us.ibm.com>2006-09-29 05:01:18 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-09-29 12:18:22 -0400
commita7422bf8a6feee6ec0c130fab7080df0cea86ebc (patch)
tree2b624eed131e8ceafb0a711827144c817ff7bf2e
parentcdae9695870895dd6be4c7d6d31d8704ea27f064 (diff)
[PATCH] loop: forward-port resource leak checks from Solar
Forward port of the patch by Solar and ported by Julio. Compiles, boots, and passes my looptorturetest.sh. Signed-off-by: Serge E. Hallyn <serue@us.ibm.com> Cc: Julio Auto <mindvortex@gmail.com> Cc: Solar Designer <solar@openwall.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--drivers/block/loop.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index e87b88731adc..68b0471ad5a6 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -820,13 +820,22 @@ static int loop_set_fd(struct loop_device *lo, struct file *lo_file,
820 lo->lo_number); 820 lo->lo_number);
821 if (IS_ERR(lo->lo_thread)) { 821 if (IS_ERR(lo->lo_thread)) {
822 error = PTR_ERR(lo->lo_thread); 822 error = PTR_ERR(lo->lo_thread);
823 lo->lo_thread = NULL; 823 goto out_clr;
824 goto out_putf;
825 } 824 }
826 lo->lo_state = Lo_bound; 825 lo->lo_state = Lo_bound;
827 wake_up_process(lo->lo_thread); 826 wake_up_process(lo->lo_thread);
828 return 0; 827 return 0;
829 828
829out_clr:
830 lo->lo_thread = NULL;
831 lo->lo_device = NULL;
832 lo->lo_backing_file = NULL;
833 lo->lo_flags = 0;
834 set_capacity(disks[lo->lo_number], 0);
835 invalidate_bdev(bdev, 0);
836 bd_set_size(bdev, 0);
837 mapping_set_gfp_mask(mapping, lo->old_gfp_mask);
838 lo->lo_state = Lo_unbound;
830 out_putf: 839 out_putf:
831 fput(file); 840 fput(file);
832 out: 841 out: