Skip to content

Commit

Permalink
[PATCH] loop: forward-port resource leak checks from Solar
Browse files Browse the repository at this point in the history
Forward port of the patch by Solar and ported by Julio.

Compiles, boots, and passes my looptorturetest.sh.

Signed-off-by: Serge E. Hallyn <[email protected]>
Cc: Julio Auto <[email protected]>
Cc: Solar Designer <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Serge E. Hallyn authored and Linus Torvalds committed Sep 29, 2006
1 parent cdae969 commit a7422bf
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions drivers/block/loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit a7422bf

Please sign in to comment.