summaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorSerge E. Hallyn <serue@us.ibm.com>2006-09-29 02:01:18 -0700
committerLinus Torvalds <torvalds@g5.osdl.org>2006-09-29 09:18:22 -0700
commita7422bf8a6feee6ec0c130fab7080df0cea86ebc (patch)
tree2b624eed131e8ceafb0a711827144c817ff7bf2e /drivers/block
parentcdae9695870895dd6be4c7d6d31d8704ea27f064 (diff)
downloadop-kernel-dev-a7422bf8a6feee6ec0c130fab7080df0cea86ebc.zip
op-kernel-dev-a7422bf8a6feee6ec0c130fab7080df0cea86ebc.tar.gz
[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>
Diffstat (limited to 'drivers/block')
-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 e87b887..68b0471 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,
lo->lo_number);
if (IS_ERR(lo->lo_thread)) {
error = PTR_ERR(lo->lo_thread);
- lo->lo_thread = NULL;
- goto out_putf;
+ goto out_clr;
}
lo->lo_state = Lo_bound;
wake_up_process(lo->lo_thread);
return 0;
+out_clr:
+ lo->lo_thread = NULL;
+ lo->lo_device = NULL;
+ lo->lo_backing_file = NULL;
+ lo->lo_flags = 0;
+ set_capacity(disks[lo->lo_number], 0);
+ invalidate_bdev(bdev, 0);
+ bd_set_size(bdev, 0);
+ mapping_set_gfp_mask(mapping, lo->old_gfp_mask);
+ lo->lo_state = Lo_unbound;
out_putf:
fput(file);
out:
OpenPOWER on IntegriCloud