diff options
author | Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp> | 2021-08-25 18:31:03 +0200 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2021-08-25 22:20:08 +0200 |
commit | 93f63bc41f699318807df202a175d564c26bda87 (patch) | |
tree | c6415a1cd974836f8c23c637d571249749500930 /drivers/block | |
parent | Merge tag 'nvme-5.15-2021-08-18' of git://git.infradead.org/nvme into for-5.1... (diff) | |
download | linux-93f63bc41f699318807df202a175d564c26bda87.tar.xz linux-93f63bc41f699318807df202a175d564c26bda87.zip |
nbd: add missing locking to the nbd_dev_add error path
idr_remove needs external synchronization.
Fixes: 6e4df4c64881 ("nbd: reduce the nbd_index_mutex scope")
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
[hch: split from a larger patch]
Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20210825163108.50713-2-hch@lst.de
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/block')
-rw-r--r-- | drivers/block/nbd.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 379032a64a7c..0c1389da3066 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -1770,7 +1770,9 @@ static struct nbd_device *nbd_dev_add(int index, unsigned int refs) return nbd; out_free_idr: + mutex_lock(&nbd_index_mutex); idr_remove(&nbd_index_idr, index); + mutex_unlock(&nbd_index_mutex); out_free_tags: blk_mq_free_tag_set(&nbd->tag_set); out_free_nbd: |