aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTetsuo Handa <[email protected]>2021-08-25 18:31:06 +0200
committerJens Axboe <[email protected]>2021-08-25 14:20:25 -0600
commitb190300decb352a0b865d7aa379e89b17d772a43 (patch)
tree1955da9e0646722af7e53ddb4f637df9d32cba41
parent75b7f62aa65d5c496391ec2c3db3561aaf81a403 (diff)
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 <[email protected]> [hch: split from a larger patch] Signed-off-by: Christoph Hellwig <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Josef Bacik <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
-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)) {