[lkml]   [2006]   [Mar]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    Patch in this message
    Subject[PATCH] loop: potential kernel hang waiting for kthread

    Hi Andrew! Folks!

    just stumbled over the following issue with loop_set_fd()
    calling kernel_thread(loop_thread), ignoring the return
    value, even if it is an error, then doing wait_for_completion()
    on the device, which, in beforementioned error case, would
    wait forever (keeping a process stuck in 'D' state)

    I can imagine at least three other solutions, but this
    one seemed quite organic to me, YMMV ...


    Signed-off-by: Herbert Poetzl <>
    --- linux/drivers/block/loop.c 2006-03-24 03:37:07 +0100
    +++ linux/drivers/block/loop.c 2006-03-25 02:30:37 +0100
    @@ -747,6 +747,7 @@ static int loop_set_fd(struct loop_devic
    int lo_flags = 0;
    int error;
    loff_t size;
    + pid_t pid;

    /* This is safe, since we have a reference from open(). */
    @@ -839,10 +840,14 @@ static int loop_set_fd(struct loop_devic

    set_blocksize(bdev, lo_blocksize);

    - kernel_thread(loop_thread, lo, CLONE_KERNEL);
    + pid = kernel_thread(loop_thread, lo, CLONE_KERNEL);
    + if (pid < 0)
    + goto out_err;
    return 0;

    + out_err:
    + error = (int)pid;
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    More majordomo info at
    Please read the FAQ at
     \ /
      Last update: 2006-03-25 02:51    [W:0.020 / U:71.820 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site