Skip to content

Commit

Permalink
nbd: Fix incorrect error handle when first_minor is illegal in nbd_de…
Browse files Browse the repository at this point in the history
…v_add

If first_minor is illegal will goto out_free_idr label, this will miss
cleanup disk.

Fixes: b1a8116 ("block: nbd: add sanity check for first_minor")
Signed-off-by: Ye Bin <yebin10@huawei.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Link: https://lore.kernel.org/r/20211102015237.2309763-4-yebin10@huawei.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Ye Bin authored and axboe committed Nov 2, 2021
1 parent 940c264 commit 69beb62
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/block/nbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1814,7 +1814,7 @@ static struct nbd_device *nbd_dev_add(int index, unsigned int refs)
disk->first_minor = index << part_shift;
if (disk->first_minor < index || disk->first_minor > MINORMASK) {
err = -EINVAL;
goto out_free_idr;
goto out_err_disk;
}

disk->minors = 1 << part_shift;
Expand Down

0 comments on commit 69beb62

Please sign in to comment.