Commit b190300d authored by Tetsuo Handa's avatar Tetsuo Handa Committed by Jens Axboe

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: 6e4df4c6 ("nbd: reduce the nbd_index_mutex scope")
Signed-off-by: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
[hch: split from a larger patch]
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20210825163108.50713-5-hch@lst.deReviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 75b7f62a
...@@ -1720,10 +1720,10 @@ static struct nbd_device *nbd_dev_add(int index, unsigned int refs) ...@@ -1720,10 +1720,10 @@ static struct nbd_device *nbd_dev_add(int index, unsigned int refs)
if (err >= 0) if (err >= 0)
index = err; index = err;
} }
nbd->index = index;
mutex_unlock(&nbd_index_mutex); mutex_unlock(&nbd_index_mutex);
if (err < 0) if (err < 0)
goto out_free_tags; goto out_free_tags;
nbd->index = index;
disk = blk_mq_alloc_disk(&nbd->tag_set, NULL); disk = blk_mq_alloc_disk(&nbd->tag_set, NULL);
if (IS_ERR(disk)) { if (IS_ERR(disk)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment