diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-08 03:21:31 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-08 03:21:31 +0000 |
commit | 5dca02f2ee931aef66bb21dd8067c8b1af1e0d3e (patch) | |
tree | 6581b770eb1bd6cac1252a5451b89c092ea4c797 /drivers/block/null_blk_main.c | |
parent | Adding debian version 4.19.249-2. (diff) | |
download | linux-5dca02f2ee931aef66bb21dd8067c8b1af1e0d3e.tar.xz linux-5dca02f2ee931aef66bb21dd8067c8b1af1e0d3e.zip |
Merging upstream version 4.19.260.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'drivers/block/null_blk_main.c')
-rw-r--r-- | drivers/block/null_blk_main.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c index 4fef1fb91..5553df736 100644 --- a/drivers/block/null_blk_main.c +++ b/drivers/block/null_blk_main.c @@ -1819,8 +1819,13 @@ static int null_add_dev(struct nullb_device *dev) blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, nullb->q); mutex_lock(&lock); - nullb->index = ida_simple_get(&nullb_indexes, 0, 0, GFP_KERNEL); - dev->index = nullb->index; + rv = ida_simple_get(&nullb_indexes, 0, 0, GFP_KERNEL); + if (rv < 0) { + mutex_unlock(&lock); + goto out_cleanup_zone; + } + nullb->index = rv; + dev->index = rv; mutex_unlock(&lock); blk_queue_logical_block_size(nullb->q, dev->blocksize); @@ -1832,13 +1837,16 @@ static int null_add_dev(struct nullb_device *dev) rv = null_gendisk_register(nullb); if (rv) - goto out_cleanup_zone; + goto out_ida_free; mutex_lock(&lock); list_add_tail(&nullb->list, &nullb_list); mutex_unlock(&lock); return 0; + +out_ida_free: + ida_free(&nullb_indexes, nullb->index); out_cleanup_zone: if (dev->zoned) null_zone_exit(dev); |