Skip to content

Commit 2762ff0

Browse files
mcgrofaxboe
authored andcommitted
nvdimm/btt: use goto error labels on btt_blk_init()
This will make it easier to share common error paths. Reviewed-by: Dan Williams <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Luis Chamberlain <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 18c6c96 commit 2762ff0

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

drivers/nvdimm/btt.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,6 +1519,7 @@ static int btt_blk_init(struct btt *btt)
15191519
{
15201520
struct nd_btt *nd_btt = btt->nd_btt;
15211521
struct nd_namespace_common *ndns = nd_btt->ndns;
1522+
int rc = -ENOMEM;
15221523

15231524
btt->btt_disk = blk_alloc_disk(NUMA_NO_NODE);
15241525
if (!btt->btt_disk)
@@ -1534,19 +1535,22 @@ static int btt_blk_init(struct btt *btt)
15341535
blk_queue_flag_set(QUEUE_FLAG_NONROT, btt->btt_disk->queue);
15351536

15361537
if (btt_meta_size(btt)) {
1537-
int rc = nd_integrity_init(btt->btt_disk, btt_meta_size(btt));
1538-
1539-
if (rc) {
1540-
blk_cleanup_disk(btt->btt_disk);
1541-
return rc;
1542-
}
1538+
rc = nd_integrity_init(btt->btt_disk, btt_meta_size(btt));
1539+
if (rc)
1540+
goto out_cleanup_disk;
15431541
}
1542+
15441543
set_capacity(btt->btt_disk, btt->nlba * btt->sector_size >> 9);
15451544
device_add_disk(&btt->nd_btt->dev, btt->btt_disk, NULL);
1545+
15461546
btt->nd_btt->size = btt->nlba * (u64)btt->sector_size;
15471547
nvdimm_check_and_set_ro(btt->btt_disk);
15481548

15491549
return 0;
1550+
1551+
out_cleanup_disk:
1552+
blk_cleanup_disk(btt->btt_disk);
1553+
return rc;
15501554
}
15511555

15521556
static void btt_blk_cleanup(struct btt *btt)

0 commit comments

Comments
 (0)