From nobody Fri Nov 29 18:30:57 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=1632780468; cv=none; d=zohomail.com; s=zohoarc; b=LVYT9G4+IIbz1tne3d+/T848PdhtsYmdBHpZFb30Y9xLRXdCBxqXFGH/GPG/9V5D8L4G/xTBe/7tP3NqMFH6xJzifNW1b2yV8lGvVxSrlNRcPOAWdtPNQ0H7RQ8SWvWffW7iPGRT63FOikQsk4Ma243mPmnT9rN2CLgyoMnHr9E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632780468; 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=vzfFGe77MiDtDAcsNEd4FFV6XUqpkLp7v2/+XiGswys=; b=GAdoZnZ6flhQG023LPxHrh0DBLpTruNuUGhzScwnyc4jsDbnC27uuz9TJRfM9lilyx+0hRpYWz7GwZ9m8r2BdlRoIKkJP68BLYvnswIETZQ/jmHl7wkViyD0qwI04sjJJH+x+H+sGigCfl4CREuaGJIHuMVEXMO6BTZ4QIkmLCs= 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 1632780468037344.6108219288493; Mon, 27 Sep 2021 15:07:48 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.197253.350287 (Exim 4.92) (envelope-from ) id 1mUyme-0007VP-Nz; Mon, 27 Sep 2021 22:07:36 +0000 Received: by outflank-mailman (output) from mailman id 197253.350287; Mon, 27 Sep 2021 22:07:36 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mUyme-0007V4-Jp; Mon, 27 Sep 2021 22:07:36 +0000 Received: by outflank-mailman (input) for mailman id 197253; Mon, 27 Sep 2021 22:07:35 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mUygv-0000mS-FF for xen-devel@lists.xenproject.org; Mon, 27 Sep 2021 22:01:41 +0000 Received: from bombadil.infradead.org (unknown [2607:7c80:54:e::133]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id f6487bb8-665e-4e21-b066-64e0c942043c; Mon, 27 Sep 2021 22:00:53 +0000 (UTC) Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mUyfw-004Sua-BV; 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: f6487bb8-665e-4e21-b066-64e0c942043c 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=vzfFGe77MiDtDAcsNEd4FFV6XUqpkLp7v2/+XiGswys=; b=1IjRffMWToIuI5hlT0QDQQle10 h2cmW94BFoi6hungxxRyemGHngj6jAyo6qgzCDtNwyoUIWdx8yZsIACgBw+d6Nd4692A4UqE77TGE FCZRmyjQTpFaOofQoJtOcS2Pkb2YvtxiwdI6lkhFHGjLfTo7fvE2zEi7m6m4dPHjKrCOvij4KUPWH DSYAexzPrZhtGZMXRAVrRoXp4+plHqrbeuTjWRI7g5ndnkdAFIDfDHEv6r0wdbAfWet/1/8nTrT68 8nOiI5xCjxlwlC2oda7p9NvctMKAA8h8pcRZ7GYw/ktOiSjdKEDnnDoQuyC514ICPIyH9sAgE7omc UHhUFlIg==; 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 01/10] block/brd: add error handling support for add_disk() Date: Mon, 27 Sep 2021 15:00:30 -0700 Message-Id: <20210927220039.1064193-2-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: 1632780469370100001 Content-Type: text/plain; charset="utf-8" We never checked for errors on add_disk() as this function returned void. Now that this is fixed, use the shiny new error handling. Signed-off-by: Luis Chamberlain --- drivers/block/brd.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/block/brd.c b/drivers/block/brd.c index 58ec167aa018..c2bf4946f4e3 100644 --- a/drivers/block/brd.c +++ b/drivers/block/brd.c @@ -372,6 +372,7 @@ static int brd_alloc(int i) struct brd_device *brd; struct gendisk *disk; char buf[DISK_NAME_LEN]; + int err =3D -ENOMEM; =20 brd =3D kzalloc(sizeof(*brd), GFP_KERNEL); if (!brd) @@ -410,14 +411,19 @@ static int brd_alloc(int i) /* Tell the block layer that this is not a rotational device */ blk_queue_flag_set(QUEUE_FLAG_NONROT, disk->queue); blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, disk->queue); - add_disk(disk); + err =3D add_disk(disk); + if (err) + goto out_cleanup_disk; + list_add_tail(&brd->brd_list, &brd_devices); =20 return 0; =20 +out_cleanup_disk: + blk_cleanup_disk(disk); out_free_dev: kfree(brd); - return -ENOMEM; + return err; } =20 static void brd_probe(dev_t dev) --=20 2.30.2