aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/nbd.c
diff options
context:
space:
mode:
authorTetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>2021-08-25 18:31:06 +0200
committerJens Axboe <axboe@kernel.dk>2021-08-25 14:20:25 -0600
commitb190300decb352a0b865d7aa379e89b17d772a43 (patch)
tree1955da9e0646722af7e53ddb4f637df9d32cba41 /drivers/block/nbd.c
parentnbd: prevent IDR lookups from finding partially initialized devices (diff)
downloadlinux-dev-b190300decb352a0b865d7aa379e89b17d772a43.tar.xz
linux-dev-b190300decb352a0b865d7aa379e89b17d772a43.zip
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: 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-5-hch@lst.de Reviewed-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/block/nbd.c')
-rw-r--r--drivers/block/nbd.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index b1ed2360ef32..6a832bf81647 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -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)) {