From nobody Mon Feb 9 01:20:50 2026 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=1634340711; cv=none; d=zohomail.com; s=zohoarc; b=ZKxNiVqu4NKKkunHC8t7Va1Czg131zt4VVvSkdkQn6zexgvEAuamx63HLx6TU0Hcn5uIjjDcxodW/6t4BzN24vsw6wGldt0YUfL69zUIUdqPxFGlOQIclrph0bARiBsnz1VtDPSD/5yLnDqUdjsHn2vtJDcF+gsLGD0i6mgKdUs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1634340711; 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=hYL8LO+ietZVLiEWE2oEBW5mwRVdCiTP81FH5yaWaJI=; b=mE0iTYS7CYTYUpEEfnYdxzpSdPk0ZPcWbwVHAfdWJxUJaCK5UIjxEJgza3ThAaHmODeIcOIWT7ZCd05WFvGGJA/rZVnz9nmLSbI0BykNhx0itiMsowXf9VjC2xuiLLMBRC2oKb0J7ZwVKO0c+P+H9bElhuSpenSlG79BbwU5v+A= 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 1634340711689979.4284792842004; Fri, 15 Oct 2021 16:31:51 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.211147.368328 (Exim 4.92) (envelope-from ) id 1mbWfq-0004KB-8O; Fri, 15 Oct 2021 23:31:38 +0000 Received: by outflank-mailman (output) from mailman id 211147.368328; Fri, 15 Oct 2021 23:31:38 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mbWfq-0004Jl-45; Fri, 15 Oct 2021 23:31:38 +0000 Received: by outflank-mailman (input) for mailman id 211147; Fri, 15 Oct 2021 23:31:37 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mbWfp-0000i4-4a for xen-devel@lists.xenproject.org; Fri, 15 Oct 2021 23:31:37 +0000 Received: from bombadil.infradead.org (unknown [2607:7c80:54:e::133]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 1469910f-8477-418a-950d-d21ea64b40cf; Fri, 15 Oct 2021 23:30:58 +0000 (UTC) Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mbWej-0095uz-9F; Fri, 15 Oct 2021 23:30:29 +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: 1469910f-8477-418a-950d-d21ea64b40cf 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=hYL8LO+ietZVLiEWE2oEBW5mwRVdCiTP81FH5yaWaJI=; b=f+ADLXwubj85qcYLZJoMkaccF0 LA88l99fFG2x11Wj0W927MuLNzxH+aLXSi41Sta0kPK0c00mcuAfJRMhRo8O2/gVT8jFEkt0Zk4hr nRpIIyZaEygIxOu2Ir+1WF5xTs39HUTMf1P+eojMMuW0QLIF0wbil/OQxvEmzd64iDDxrFcmE+0yv kE8A86cACAhv+x1ja677g+NC4hNwoUKBXx1xqWEMK3YQiQVLgxdzr8G77MuSAupgfSMZX4TFT1Edb SbvQjQ/3HgQObpF99DOxhOoPdReW+f1FUge3qPoQJgqPVxOn1VIhcnU4ycnlt6M5auGj2buchrJJi DE0a5Yog==; From: Luis Chamberlain To: axboe@kernel.dk, jejb@linux.ibm.com, martin.petersen@oracle.com, agk@redhat.com, snitzer@redhat.com, colyli@suse.de, kent.overstreet@gmail.com, boris.ostrovsky@oracle.com, jgross@suse.com, sstabellini@kernel.org, roger.pau@citrix.com, geert@linux-m68k.org, ulf.hansson@linaro.org, tj@kernel.org, hare@suse.de, jdike@addtoit.com, richard@nod.at, anton.ivanov@cambridgegreys.com, johannes.berg@intel.com, krisman@collabora.com, chris.obbard@collabora.com, thehajime@gmail.com, zhuyifei1999@gmail.com, haris.iqbal@ionos.com, jinpu.wang@ionos.com, miquel.raynal@bootlin.com, vigneshr@ti.com, linux-mtd@lists.infradead.org Cc: linux-scsi@vger.kernel.org, dm-devel@redhat.com, linux-bcache@vger.kernel.org, xen-devel@lists.xenproject.org, linux-m68k@lists.linux-m68k.org, linux-um@lists.infradead.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Luis Chamberlain Subject: [PATCH 4/9] bcache: add error handling support for add_disk() Date: Fri, 15 Oct 2021 16:30:23 -0700 Message-Id: <20211015233028.2167651-5-mcgrof@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211015233028.2167651-1-mcgrof@kernel.org> References: <20211015233028.2167651-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: 1634340713257100001 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. This driver doesn't do any unwinding with blk_cleanup_disk() even on errors after add_disk() and so we follow that tradition. Acked-by: Coly Li Signed-off-by: Luis Chamberlain --- drivers/md/bcache/super.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c index f2874c77ff79..f0c32cdd6594 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -1082,7 +1082,9 @@ int bch_cached_dev_run(struct cached_dev *dc) closure_sync(&cl); } =20 - add_disk(d->disk); + ret =3D add_disk(d->disk); + if (ret) + goto out; bd_link_disk_holder(dc->bdev, dc->disk.disk); /* * won't show up in the uevent file, use udevadm monitor -e instead @@ -1534,10 +1536,11 @@ static void flash_dev_flush(struct closure *cl) =20 static int flash_dev_run(struct cache_set *c, struct uuid_entry *u) { + int err =3D -ENOMEM; struct bcache_device *d =3D kzalloc(sizeof(struct bcache_device), GFP_KERNEL); if (!d) - return -ENOMEM; + goto err_ret; =20 closure_init(&d->cl, NULL); set_closure_fn(&d->cl, flash_dev_flush, system_wq); @@ -1551,9 +1554,12 @@ static int flash_dev_run(struct cache_set *c, struct= uuid_entry *u) bcache_device_attach(d, c, u - c->uuids); bch_sectors_dirty_init(d); bch_flash_dev_request_init(d); - add_disk(d->disk); + err =3D add_disk(d->disk); + if (err) + goto err; =20 - if (kobject_add(&d->kobj, &disk_to_dev(d->disk)->kobj, "bcache")) + err =3D kobject_add(&d->kobj, &disk_to_dev(d->disk)->kobj, "bcache"); + if (err) goto err; =20 bcache_device_link(d, c, "volume"); @@ -1567,7 +1573,8 @@ static int flash_dev_run(struct cache_set *c, struct = uuid_entry *u) return 0; err: kobject_put(&d->kobj); - return -ENOMEM; +err_ret: + return err; } =20 static int flash_devs_run(struct cache_set *c) --=20 2.30.2