提交 93f63bc4 编写于 作者: T Tetsuo Handa 提交者: Jens Axboe

nbd: add missing locking to the nbd_dev_add error path

idr_remove needs external synchronization.

Fixes: 6e4df4c6 ("nbd: reduce the nbd_index_mutex scope")
Signed-off-by: NTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
[hch: split from a larger patch]
Signed-off-by: NChristoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20210825163108.50713-2-hch@lst.deReviewed-by: NJosef Bacik <josef@toxicpanda.com>
Signed-off-by: NJens Axboe <axboe@kernel.dk>
上级 ca27f5b5
...@@ -1770,7 +1770,9 @@ static struct nbd_device *nbd_dev_add(int index, unsigned int refs) ...@@ -1770,7 +1770,9 @@ static struct nbd_device *nbd_dev_add(int index, unsigned int refs)
return nbd; return nbd;
out_free_idr: out_free_idr:
mutex_lock(&nbd_index_mutex);
idr_remove(&nbd_index_idr, index); idr_remove(&nbd_index_idr, index);
mutex_unlock(&nbd_index_mutex);
out_free_tags: out_free_tags:
blk_mq_free_tag_set(&nbd->tag_set); blk_mq_free_tag_set(&nbd->tag_set);
out_free_nbd: out_free_nbd:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册