nbd: set nbd->index before releasing nbd_index_mutex
Set nbd->index before releasing nbd_index_mutex, as populate_nbd_status()
might access nbd->index as soon as nbd_index_mutex is released.
Fixes: 6e4df4c648
("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-5-hch@lst.de
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
75b7f62aa6
commit
b190300dec
@ -1720,10 +1720,10 @@ static struct nbd_device *nbd_dev_add(int index, unsigned int refs)
|
||||
if (err >= 0)
|
||||
index = err;
|
||||
}
|
||||
nbd->index = index;
|
||||
mutex_unlock(&nbd_index_mutex);
|
||||
if (err < 0)
|
||||
goto out_free_tags;
|
||||
nbd->index = index;
|
||||
|
||||
disk = blk_mq_alloc_disk(&nbd->tag_set, NULL);
|
||||
if (IS_ERR(disk)) {
|
||||
|
Loading…
Reference in New Issue
Block a user