lkml.org 
[lkml]   [2013]   [Feb]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[PATCH 22.5/77] block/loop: fix error return value in loop_add()
    If queue or disk allocation fails, loop_add() returns @err, which is
    cleared to zero by idr allocation by that point. Reset @err to
    -ENOMEM before the allocations so that we return -ENOMEM instead of 0
    on alloc failure.

    Signed-off-by: Tejun Heo <tj@kernel.org>
    Cc: Jens Axboe <axboe@kernel.dk>
    Cc: stable@vger.kernel.org
    ---
    Hey, guys.

    I was going through the conversions one more time and noticed this
    existing bug. We're returning 0 on alloc failure. It seems the worst
    which can come out of this is userland misled to believe a loop device
    has been created when in fact it failed. This can be routed
    separately but it probably is easier to route with other changes.

    Thanks!

    drivers/block/loop.c | 1 +
    1 file changed, 1 insertion(+)

    --- a/drivers/block/loop.c
    +++ b/drivers/block/loop.c
    @@ -1649,6 +1649,7 @@ static int loop_add(struct loop_device *
    if (err < 0)
    goto out_free_dev;

    + err = -ENOMEM;
    lo->lo_queue = blk_alloc_queue(GFP_KERNEL);
    if (!lo->lo_queue)
    goto out_free_dev;

    \
     
     \ /
      Last update: 2013-02-07 20:02    [W:2.570 / U:0.144 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site