From nobody Fri Nov 29 19:45:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1632780084; cv=none; d=zohomail.com; s=zohoarc; b=R7dOT4PVSsxXIeLXMDAj73DEGW00gUOYUdkZm6WwkdQfMVsy4Kx09zNaRVrXZQEPvdZ7AJIMipgAHtD6sYQVH2RbPoGcGD6OqwYlo/nlLuvGDbUTMp0VwgO7XseZpfVfu9v1SSk1JcyKuEcv4vAzCFedmd8ysDz8w2MU9TOfKWQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632780084; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vmoV/2yvLiwBFQQklXCjpC+/vAkb2GZd/kil2P+K9LY=; b=k4FCsBfygFp4HYbGvYl/8OEtG523+TdqIewoYuRbUoGeccXJKQBYJwQUAWno7Tc0nMhCtdAH6MrlVYll7Q5SfJmmqVPuwSONFARMMRJWw9E/WiQ7GeEEnF8rC5HMjz0mb4ByxZ0Ts+Kz9j3+ebDtNyM79mZ28awIdkAJXicE8mE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 163278008406357.05064123553268; Mon, 27 Sep 2021 15:01:24 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.197197.350164 (Exim 4.92) (envelope-from ) id 1mUygB-0000mh-P4; Mon, 27 Sep 2021 22:00:55 +0000 Received: by outflank-mailman (output) from mailman id 197197.350164; Mon, 27 Sep 2021 22:00:55 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mUygB-0000ma-M9; Mon, 27 Sep 2021 22:00:55 +0000 Received: by outflank-mailman (input) for mailman id 197197; Mon, 27 Sep 2021 22:00:54 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mUyg7-0000mS-Gr for xen-devel@lists.xenproject.org; Mon, 27 Sep 2021 22:00:54 +0000 Received: from bombadil.infradead.org (unknown [2607:7c80:54:e::133]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id a842f28d-6bee-44e0-8ddd-7e048daccf24; Mon, 27 Sep 2021 22:00:48 +0000 (UTC) Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mUyfw-004Sv0-HC; Mon, 27 Sep 2021 22:00:40 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list X-Inumbo-ID: a842f28d-6bee-44e0-8ddd-7e048daccf24 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=1N4JPqGLhLSNsS1Cgb2YIwsly7 +aW4YwpCslJYpkXAks9L5PAknlJFJXGDyS2ZEpaD2M0hKp7uuxemDnq0kmn0PiKNEhZfT3xU5OE2B NEIidZ82kagd9xiTvY4QBVhmfjUldvqMwEvJy3GCCTADP8JJLfZaVXaqvSZjYvDbf4jwE6N+/UCCO nFCZarCbKs9WvILUUJzj8n4GKX9IADqiqMHNghfdRfc0+glrPy84n7AImXEvFcu5sIum2O+W4K3/v voAp9xetJTWmWSHjJcDRqvnSUKtPXEmI0SsH4et/rU0BJwVZAwXRe6CxRMvzIZNqW955VNmdGfG+F VLf4/Vkw==; 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 v2 05/10] nvdimm/btt: use goto error labels on btt_blk_init() Date: Mon, 27 Sep 2021 15:00:34 -0700 Message-Id: <20210927220039.1064193-6-mcgrof@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210927220039.1064193-1-mcgrof@kernel.org> References: <20210927220039.1064193-1-mcgrof@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Luis Chamberlain X-ZohoMail-DKIM: pass (identity @infradead.org) X-ZM-MESSAGEID: 1632780085140100007 Content-Type: text/plain; charset="utf-8" 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 =3D btt->nd_btt; struct nd_namespace_common *ndns =3D nd_btt->ndns; + int rc =3D -ENOMEM; =20 btt->btt_disk =3D blk_alloc_disk(NUMA_NO_NODE); if (!btt->btt_disk) - return -ENOMEM; + goto out; =20 nvdimm_namespace_disk_name(ndns, btt->btt_disk->disk_name); btt->btt_disk->first_minor =3D 0; @@ -1535,19 +1536,23 @@ static int btt_blk_init(struct btt *btt) blk_queue_flag_set(QUEUE_FLAG_NONROT, btt->btt_disk->queue); =20 if (btt_meta_size(btt)) { - int rc =3D nd_integrity_init(btt->btt_disk, btt_meta_size(btt)); - - if (rc) { - blk_cleanup_disk(btt->btt_disk); - return rc; - } + rc =3D 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 =3D btt->nlba * (u64)btt->sector_size; nvdimm_check_and_set_ro(btt->btt_disk); =20 return 0; + +out_cleanup_disk: + blk_cleanup_disk(btt->btt_disk); +out: + return rc; } =20 static void btt_blk_cleanup(struct btt *btt) --=20 2.30.2