]> www.infradead.org Git - users/hch/block.git/commitdiff
nbd: add missing locking to the nbd_dev_add error path
authorTetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Wed, 25 Aug 2021 09:47:41 +0000 (11:47 +0200)
committerChristoph Hellwig <hch@lst.de>
Wed, 25 Aug 2021 12:38:13 +0000 (14:38 +0200)
idr_remove needs external synchronization.

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>
drivers/block/nbd.c

index c5e2b4cd697fa970e484a05541ef7d06ec9eed70..2c63372a31dd5fb57078ae826efa39d0805ddf96 100644 (file)
@@ -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: