From: Tetsuo Handa <penguin-kernel@xxxxxxxxxxxxxxxxxxx> idr_remove needs external synchronization. Fixes: 6e4df4c64881 ("nbd: reduce the nbd_index_mutex scope") Signed-off-by: Tetsuo Handa <penguin-kernel@xxxxxxxxxxxxxxxxxxx> [hch: split from a larger patch] Signed-off-by: Christoph Hellwig <hch@xxxxxx> --- drivers/block/nbd.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index c5e2b4cd697f..2c63372a31dd 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -1774,7 +1774,9 @@ static struct nbd_device *nbd_dev_add(int index, unsigned int refs) return nbd; out_free_idr: + mutex_lock(&nbd_index_mutex); idr_remove(&nbd_index_idr, index); + mutex_unlock(&nbd_index_mutex); out_free_tags: blk_mq_free_tag_set(&nbd->tag_set); out_free_nbd: -- 2.30.2