Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1590196pxb; Fri, 27 Aug 2021 12:20:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxmzfvgOFQrQ36mRhW3LC+gkUtgOS74GVmqts9SdselhqagkVp3fM6fcdq37FKxzGtlc62M X-Received: by 2002:a05:6e02:531:: with SMTP id h17mr7668724ils.288.1630092037972; Fri, 27 Aug 2021 12:20:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630092037; cv=none; d=google.com; s=arc-20160816; b=Ttkcl5YnpH7dRws7bBhwx8BX0Eqap5PyIrdS27/DkRniB41jMur2irmtayll6Kvv2g Pzrtfw5c90fQzIL16QyPJa0qFJXm3bmSwU71+9DF96UfVR0EuujZdyOMdV2VTPTF7cFx XQ0oFJPosuTV5+F6GPPs4EflgcLgRZP9Fn33BS9O0xOIq1MnDTgaZqo08xTwQ7+SSJ8r 5VukEilydRdtzYKJVcqaJmSHFhedCYf+bl7ZJnNqyESR/BiqOtp5SvU+kEWRn75W5fNp GUBdXwbXA+vwJYGWEdxuzhlvO3MKhVPFNf3HdQtE7w6+58nZXBDLq6DM3RZpSvdrt5D7 PRQw== 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=27odH5nuWhozi1ECDZZ4goiUsLRrmSNLiICgWw9rj94=; b=wQHZ7oNA7S7oNQi7ziSyH9jO31SewIkcKXX3P/Io6jfuktCkwgWZrfkqbGbeBAoSVg x3kPiVZcffzSI9UsfBPNa3j05FYe7BTtEWu/nG/PnUkssamrQYGSs1Ec+7tNqqnvLQmm qp6/LBtG9VdffSB6BTg0+PdYFRj+47826h0TC62Z4dks+imtAAUrC5TSwySUFXQMJ8o7 WjEOj2nZWp9BJnxm2KMK2kxMWqwQ6Ge+mahQqt24/OCNX7fxs/zDDe0RuK7rKOHl8WoE 6rNlwGvPqrjWKWD4NIB0s2IOwZ8ySSj1W11YMtpoCMKOe+vUx7d67Z3cKTzloNZpvsUs 1gwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=RoVROwon; 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 r13si6950054ilo.33.2021.08.27.12.20.26; Fri, 27 Aug 2021 12:20:37 -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=RoVROwon; 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 S231334AbhH0TTV (ORCPT + 99 others); Fri, 27 Aug 2021 15:19:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230493AbhH0TTO (ORCPT ); Fri, 27 Aug 2021 15:19:14 -0400 Received: from bombadil.infradead.org (unknown [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DA6BC0613CF; Fri, 27 Aug 2021 12:18:25 -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=27odH5nuWhozi1ECDZZ4goiUsLRrmSNLiICgWw9rj94=; b=RoVROwonXgehtqGc+uNEhBcWcZ R5TCqcCZrOdRGr9HUPwtMi32e/ae/EkxCUSAPtRc6M2LeT6rdituE92p30lXXWNaVFoW1e/c2e6Jb kraEvvyQ0M5bcOebJtmKBzhn/SKTI3nIuCgdJLTg8IUxMR9sn5GxY4zSbxxEz0K4wwzTyI0DP5qL4 2x+bE9BxAJsWm1ucxECHkU1A/iGQVGxBjvTqucWQarpvTa/rJT4JydPtEf/YgYxRjQJlkZQbeG6KC TpQ8GMDtI1KQRlMQi4ArGei1Q6BvaQQHz0c7jbbmvYnpnnYjjiZOxdHBsmeZG072BsLXL5mGH59Kg DQxVvblQ==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mJhMh-00D5B1-9r; Fri, 27 Aug 2021 19:18:11 +0000 From: Luis Chamberlain To: axboe@kernel.dk, colyli@suse.de, kent.overstreet@gmail.com, kbusch@kernel.org, sagi@grimberg.me, vishal.l.verma@intel.com, dan.j.williams@intel.com, dave.jiang@intel.com, ira.weiny@intel.com, konrad.wilk@oracle.com, roger.pau@citrix.com, boris.ostrovsky@oracle.com, jgross@suse.com, sstabellini@kernel.org, minchan@kernel.org, ngupta@vflare.org, senozhatsky@chromium.org Cc: xen-devel@lists.xenproject.org, nvdimm@lists.linux.dev, linux-nvme@lists.infradead.org, linux-bcache@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Luis Chamberlain Subject: [PATCH 05/10] nvdimm/btt: use goto error labels on btt_blk_init() Date: Fri, 27 Aug 2021 12:18:04 -0700 Message-Id: <20210827191809.3118103-6-mcgrof@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210827191809.3118103-1-mcgrof@kernel.org> References: <20210827191809.3118103-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 3fd1bdb9fc05..275704d80109 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