[PATCH] loop: potential kernel hang waiting for kthread
authorHerbert Poetzl <herbert@13thfloor.at>
Sun, 26 Mar 2006 09:37:30 +0000 (01:37 -0800)
committerLinus Torvalds <torvalds@g5.osdl.org>
Sun, 26 Mar 2006 16:56:57 +0000 (08:56 -0800)
Check that kernel_thread() succeeded, so we don't wait for something which
cannot happen.

Signed-off-by: Herbert Poetzl <herbert@13thfloor.at>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
drivers/block/loop.c

index 74bf0255e98f44dd2cc405426254a6e9b744f19d..9c3b94e8f03baa7d4138802e01b87e27e511c159 100644 (file)
@@ -839,7 +839,9 @@ static int loop_set_fd(struct loop_device *lo, struct file *lo_file,
 
        set_blocksize(bdev, lo_blocksize);
 
-       kernel_thread(loop_thread, lo, CLONE_KERNEL);
+       error = kernel_thread(loop_thread, lo, CLONE_KERNEL);
+       if (error < 0)
+               goto out_putf;
        wait_for_completion(&lo->lo_done);
        return 0;