Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2609431pxb; Sun, 17 Oct 2021 20:24:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYUPDHnJfEJ1N6Yhn/B9C5SdPEvwOuYV4c7FfGP9Ic5VWLcQ0T68k6aKH0Nr0KaHJTp5Mj X-Received: by 2002:a05:6a00:84b:b0:44d:afcc:3577 with SMTP id q11-20020a056a00084b00b0044dafcc3577mr10385407pfk.42.1634527462726; Sun, 17 Oct 2021 20:24:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634527462; cv=none; d=google.com; s=arc-20160816; b=pXocP02bYKg49jzC57NrO70b6V+nLDlX75PPBZr23DQalgPzQpmkUHPUejfwvSX1T1 Rg5g6/qg0tBr/ZG9/3Dm3dTPBX5z/V2uDHjNx1/xEKz1JCX3ha4kPAfSp5yjJoB4X5CR PZjplJqd//+e989ZrL44rhnhWxNM2IWdfCRqVaxa6Idcx2NHBnRdaOGvyftuYYkLtkkC sL3Pr4cV8ZCXOKIhlYe1YPS3zy8DRaY4V5tXq8n3pOnqlE/ZXAgaMLDe0fILTAnzU4JZ 6q8eyFrmCJ6rfZQ2r96EBEvxVQq7X7pRPXsac9NNU7bl6xbKra8U2byiuRNGzdYjY14V FevQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vmoV/2yvLiwBFQQklXCjpC+/vAkb2GZd/kil2P+K9LY=; b=PRnu68oxQ+85MyqyAB7QITPLSinIJ30mAgslSrA76jD1CjbQLphGHF0r21Lw/Z0gOE aE6exmlqlZsIAy+ZgGjNO16Thc2+A/Mj4FGVMQ/9m8M2O3IaQkzROBRB3AIHf6HgJL1F ctDm9FM0uwBB1XTHqW+O9HxlgVepzW1qm4hoyr3dOpeuxfVKrRT/ApPQ1QYrPfex1tzx tmxjCPzzCT28dtFck8Ati1eB1td0ZePWGM+oi6Gs8eSiX/Ox2ry3rtm5CIHY6ax3CiwD GHVtwquWRpp4mgqW56PgixgvOxEZ/BhFlKlRTTB4fLwvTtuAcgGwZv5+VprBYmImWuNj 1FzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=k0iIsRd4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z24si281312pgj.69.2021.10.17.20.24.10; Sun, 17 Oct 2021 20:24:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=k0iIsRd4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239094AbhJOXzG (ORCPT + 98 others); Fri, 15 Oct 2021 19:55:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229546AbhJOXzE (ORCPT ); Fri, 15 Oct 2021 19:55:04 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 959C3C061762; Fri, 15 Oct 2021 16:52:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=vmoV/2yvLiwBFQQklXCjpC+/vAkb2GZd/kil2P+K9LY=; b=k0iIsRd4etFUTdob28o4ORiDN4 +B5FyF731o7hr+GINXvlvMEAMpsLwW5pC/OKgrZhFwyicCWbpFYSPPBTrBIjvSuVnrLjhUSLYS++y oRkzDGAOTsEh93X+qg4nyS4uWEdS1lTDNed0oMklQ8zbFZvEmtlBlaap7C7u4S3ktr+flejwhLn6v kgxKkRW5rGqDNa6Cku4cssrBYgKN0s5RFNPfDoSHCSG9iQEucDFOEf6fvVjlMBFP7jCkT/hLFNSOo cpEoBq/XBYeFkTadkfricUfOXARU2LfOTVXw3vn1MHJ8F/i5S8b+Km/fw6MNqjRctXbmhviSiCcL6 I9TcNhtA==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mbWzt-009C31-2Y; Fri, 15 Oct 2021 23:52:21 +0000 From: Luis Chamberlain To: axboe@kernel.dk, geoff@infradead.org, mpe@ellerman.id.au, benh@kernel.crashing.org, paulus@samba.org, jim@jtan.com, minchan@kernel.org, ngupta@vflare.org, senozhatsky@chromium.org, richard@nod.at, miquel.raynal@bootlin.com, vigneshr@ti.com, dan.j.williams@intel.com, vishal.l.verma@intel.com, dave.jiang@intel.com, ira.weiny@intel.com, kbusch@kernel.org, hch@lst.de, sagi@grimberg.me Cc: linux-block@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-mtd@lists.infradead.org, nvdimm@lists.linux.dev, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Luis Chamberlain Subject: [PATCH 04/13] nvdimm/btt: use goto error labels on btt_blk_init() Date: Fri, 15 Oct 2021 16:52:10 -0700 Message-Id: <20211015235219.2191207-5-mcgrof@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211015235219.2191207-1-mcgrof@kernel.org> References: <20211015235219.2191207-1-mcgrof@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: Luis Chamberlain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This will make it easier to share common error paths. Signed-off-by: Luis Chamberlain --- drivers/nvdimm/btt.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/nvdimm/btt.c b/drivers/nvdimm/btt.c index 29cc7325e890..23ee8c005db5 100644 --- a/drivers/nvdimm/btt.c +++ b/drivers/nvdimm/btt.c @@ -1520,10 +1520,11 @@ 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) - return -ENOMEM; + goto out; nvdimm_namespace_disk_name(ndns, btt->btt_disk->disk_name); btt->btt_disk->first_minor = 0; @@ -1535,19 +1536,23 @@ 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); +out: + return rc; } static void btt_blk_cleanup(struct btt *btt) -- 2.30.2