Messages in this thread Patch in this message | | | Date | Thu, 7 Feb 2013 10:25:26 -0800 | From | Tejun Heo <> | 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;
| |