Commit a7422bf8 authored by Serge E. Hallyn's avatar Serge E. Hallyn Committed by Linus Torvalds

[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: default avatarSerge E. Hallyn <serue@us.ibm.com>
Cc: Julio Auto <mindvortex@gmail.com>
Cc: Solar Designer <solar@openwall.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent cdae9695
...@@ -820,13 +820,22 @@ static int loop_set_fd(struct loop_device *lo, struct file *lo_file, ...@@ -820,13 +820,22 @@ static int loop_set_fd(struct loop_device *lo, struct file *lo_file,
lo->lo_number); lo->lo_number);
if (IS_ERR(lo->lo_thread)) { if (IS_ERR(lo->lo_thread)) {
error = PTR_ERR(lo->lo_thread); error = PTR_ERR(lo->lo_thread);
lo->lo_thread = NULL; goto out_clr;
goto out_putf;
} }
lo->lo_state = Lo_bound; lo->lo_state = Lo_bound;
wake_up_process(lo->lo_thread); wake_up_process(lo->lo_thread);
return 0; 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: out_putf:
fput(file); fput(file);
out: out:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment