nvdimm/btt: use goto error labels on btt_blk_init()
This will make it easier to share common error paths. Reviewed-by: Dan Williams <dan.j.williams@intel.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org> Link: https://lore.kernel.org/r/20211103230437.1639990-2-mcgrof@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
18c6c96897
commit
2762ff06aa
@ -1519,6 +1519,7 @@ static int btt_blk_init(struct btt *btt)
|
||||
{
|
||||
struct nd_btt *nd_btt = btt->nd_btt;
|
||||
struct nd_namespace_common *ndns = nd_btt->ndns;
|
||||
int rc = -ENOMEM;
|
||||
|
||||
btt->btt_disk = blk_alloc_disk(NUMA_NO_NODE);
|
||||
if (!btt->btt_disk)
|
||||
@ -1534,19 +1535,22 @@ static int btt_blk_init(struct btt *btt)
|
||||
blk_queue_flag_set(QUEUE_FLAG_NONROT, btt->btt_disk->queue);
|
||||
|
||||
if (btt_meta_size(btt)) {
|
||||
int rc = nd_integrity_init(btt->btt_disk, btt_meta_size(btt));
|
||||
|
||||
if (rc) {
|
||||
blk_cleanup_disk(btt->btt_disk);
|
||||
return rc;
|
||||
}
|
||||
rc = nd_integrity_init(btt->btt_disk, btt_meta_size(btt));
|
||||
if (rc)
|
||||
goto out_cleanup_disk;
|
||||
}
|
||||
|
||||
set_capacity(btt->btt_disk, btt->nlba * btt->sector_size >> 9);
|
||||
device_add_disk(&btt->nd_btt->dev, btt->btt_disk, NULL);
|
||||
|
||||
btt->nd_btt->size = btt->nlba * (u64)btt->sector_size;
|
||||
nvdimm_check_and_set_ro(btt->btt_disk);
|
||||
|
||||
return 0;
|
||||
|
||||
out_cleanup_disk:
|
||||
blk_cleanup_disk(btt->btt_disk);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static void btt_blk_cleanup(struct btt *btt)
|
||||
|
Loading…
x
Reference in New Issue
Block a user