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 <t...@kernel.org> Cc: Jens Axboe <ax...@kernel.dk> Cc: sta...@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; -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/