From patchwork Mon Aug 23 20:29:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 501693 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2582CC4338F for ; Mon, 23 Aug 2021 20:30:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0E9E26103A for ; Mon, 23 Aug 2021 20:30:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232767AbhHWUbF (ORCPT ); Mon, 23 Aug 2021 16:31:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232647AbhHWUay (ORCPT ); Mon, 23 Aug 2021 16:30:54 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F270FC061575; Mon, 23 Aug 2021 13:30:11 -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=PfrtPFCUd+vz1Tgg1hQkj8zJ7tYmGxUAcqUzPySlWYA=; b=yD4BOzsjmHnK5qg88RUylmmo4x LuD3Z1YAXTY3+2DEjNWJP8B8YDsBytZ5Ws7NCdyXH6+IszaNyI7RcYTgogrS1cStxeAm/VJNjQznF VNszelhZ8qUPHoYETHBXKOmV5TuUwNk6uZ5D9IsTnfKwo/d/rSMOb1805A8RyTFYRI9Im0zm4RzsM s9seiCCpfZI4ntuSYeM/w875HulOk2W/qDUW4yeGjFTVCPEOyXRPN8n2zBUoArUD5lfU3Ur41llbM 6j0unwzhFa84ekYFn58NNKW1yh7Re9B4iQQEfF8V1LfkgZOMWAxgpkMaBgejMHJmuttbRdBR+3Myq w3rQB8FA==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mIGZa-000ZjK-02; Mon, 23 Aug 2021 20:29:34 +0000 From: Luis Chamberlain To: axboe@kernel.dk, martin.petersen@oracle.com, jejb@linux.ibm.com, kbusch@kernel.org, sagi@grimberg.me, adrian.hunter@intel.com, beanhuo@micron.com, ulf.hansson@linaro.org, avri.altman@wdc.com, swboyd@chromium.org, agk@redhat.com, snitzer@redhat.com, josef@toxicpanda.com Cc: hch@infradead.org, hare@suse.de, bvanassche@acm.org, ming.lei@redhat.com, linux-scsi@vger.kernel.org, linux-nvme@lists.infradead.org, linux-mmc@vger.kernel.org, dm-devel@redhat.com, nbd@other.debian.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Luis Chamberlain Subject: [PATCH 01/10] scsi/sd: use blk_cleanup_queue() insted of put_disk() Date: Mon, 23 Aug 2021 13:29:21 -0700 Message-Id: <20210823202930.137278-2-mcgrof@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210823202930.137278-1-mcgrof@kernel.org> References: <20210823202930.137278-1-mcgrof@kernel.org> MIME-Version: 1.0 Sender: Luis Chamberlain Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The single put_disk() is useful if you know you're not doing a cleanup after add_disk(), but since we want to add support for that, just use the normal form of blk_cleanup_disk() to cleanup the queue and put the disk. Signed-off-by: Luis Chamberlain --- drivers/scsi/sd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 610ebba0d66e..7d5217905374 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -3508,7 +3508,7 @@ static int sd_probe(struct device *dev) out_free_index: ida_free(&sd_index_ida, index); out_put: - put_disk(gd); + blk_cleanup_disk(gd); out_free: sd_zbc_release_disk(sdkp); kfree(sdkp); From patchwork Mon Aug 23 20:29:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 501694 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72545C4320E for ; Mon, 23 Aug 2021 20:30:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5E2EA60E97 for ; Mon, 23 Aug 2021 20:30:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232701AbhHWUbB (ORCPT ); Mon, 23 Aug 2021 16:31:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232404AbhHWUas (ORCPT ); Mon, 23 Aug 2021 16:30:48 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0387FC06175F; Mon, 23 Aug 2021 13:30:06 -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=vcZytCs+3aE+pJZnIfeJteJaLaeBUv3H5n6Ya972Mjw=; b=aYu6mhnbiyATjp4QiEfJEQBVbf OPaaXkqiH9H7Ag7hYKlVfy/SfXLFAo1BzUouJ1s4mWbb4rq7EeHKiBhpuX2mEDBG4bgJ+nP6KMsI7 I0U91+7njxj4QNr/sb6TGWGS/DEGCDcxRb983z2ovIXySVexXWGiVRlSV9hFXRaBKeGBo4OYpnf3u zcKhdWCflmlIlZki5Pm1OPCvGe7/aSrrycL4c9juLZp8L3EC5ZEG2PnZWTJ33biaDkTyFqCtmHloC r9Cu93H5ttvttqe8KIscjnkDWRtxjRf02QD6fjQchxzWOEjnKPsDe6jFpiJfD3Gt2sTIE3ss2+87T pxfzrfMQ==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mIGZa-000ZjM-2N; Mon, 23 Aug 2021 20:29:34 +0000 From: Luis Chamberlain To: axboe@kernel.dk, martin.petersen@oracle.com, jejb@linux.ibm.com, kbusch@kernel.org, sagi@grimberg.me, adrian.hunter@intel.com, beanhuo@micron.com, ulf.hansson@linaro.org, avri.altman@wdc.com, swboyd@chromium.org, agk@redhat.com, snitzer@redhat.com, josef@toxicpanda.com Cc: hch@infradead.org, hare@suse.de, bvanassche@acm.org, ming.lei@redhat.com, linux-scsi@vger.kernel.org, linux-nvme@lists.infradead.org, linux-mmc@vger.kernel.org, dm-devel@redhat.com, nbd@other.debian.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Luis Chamberlain Subject: [PATCH 02/10] scsi/sd: add error handling support for add_disk() Date: Mon, 23 Aug 2021 13:29:22 -0700 Message-Id: <20210823202930.137278-3-mcgrof@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210823202930.137278-1-mcgrof@kernel.org> References: <20210823202930.137278-1-mcgrof@kernel.org> MIME-Version: 1.0 Sender: Luis Chamberlain Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org 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 Reviewed-by: Christoph Hellwig --- drivers/scsi/sd.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 7d5217905374..7df6f20f28ec 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -3487,7 +3487,11 @@ static int sd_probe(struct device *dev) pm_runtime_set_autosuspend_delay(dev, sdp->host->hostt->rpm_autosuspend_delay); } - device_add_disk(dev, gd, NULL); + + error = device_add_disk(dev, gd, NULL); + if (error) + goto out_free_index; + if (sdkp->capacity) sd_dif_config_host(sdkp); From patchwork Mon Aug 23 20:29:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 501692 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4738DC4338F for ; Mon, 23 Aug 2021 20:30:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 30FF360E97 for ; Mon, 23 Aug 2021 20:30:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232710AbhHWUbJ (ORCPT ); Mon, 23 Aug 2021 16:31:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232635AbhHWUaz (ORCPT ); Mon, 23 Aug 2021 16:30:55 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46E2FC061757; Mon, 23 Aug 2021 13:30:12 -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=k5sSl0vYONsVC6k5VQFocYf3UMVF7iXDLEuoRb4cPTo=; b=ytFd4wxWicN567iPDaQzopBkVb JEyVQhLcVbjxFEKZmQ7+C9EZhZzxiVUSTFuO/z4gnGAnXuDbcZcpAvJMz1ga6UMI9IdifaxeWK3+h XskXFUN+TYORj+pU/KKuAKqjZMYm2Y5SMZvnBpJ+11VvVHW9nweZLpVLJyez2gZGD5ACl5WZaqed2 GP43jjy3zwcb09a9pAqe7/u9Hj6rXJMDeI4AEU1+fv9az905SqIVvvF2mrGGMbbOU0g8BHbj3Uics 276Gt+vykqsXpBeIdrJhIRgigovtHjEdKSiXWU+TBHwwbwbj4bq+yz48vbxLGXSQ0wKNFh9P0SVNj WJK6EXfQ==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mIGZa-000ZjS-8P; Mon, 23 Aug 2021 20:29:34 +0000 From: Luis Chamberlain To: axboe@kernel.dk, martin.petersen@oracle.com, jejb@linux.ibm.com, kbusch@kernel.org, sagi@grimberg.me, adrian.hunter@intel.com, beanhuo@micron.com, ulf.hansson@linaro.org, avri.altman@wdc.com, swboyd@chromium.org, agk@redhat.com, snitzer@redhat.com, josef@toxicpanda.com Cc: hch@infradead.org, hare@suse.de, bvanassche@acm.org, ming.lei@redhat.com, linux-scsi@vger.kernel.org, linux-nvme@lists.infradead.org, linux-mmc@vger.kernel.org, dm-devel@redhat.com, nbd@other.debian.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Luis Chamberlain Subject: [PATCH 05/10] nvme: add error handling support for add_disk() Date: Mon, 23 Aug 2021 13:29:25 -0700 Message-Id: <20210823202930.137278-6-mcgrof@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210823202930.137278-1-mcgrof@kernel.org> References: <20210823202930.137278-1-mcgrof@kernel.org> MIME-Version: 1.0 Sender: Luis Chamberlain Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org 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/nvme/host/core.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 68acd33c3856..fe02e95173d8 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -3720,6 +3720,7 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid, struct gendisk *disk; struct nvme_id_ns *id; int node = ctrl->numa_node; + int rc; if (nvme_identify_ns(ctrl, nsid, ids, &id)) return; @@ -3775,7 +3776,10 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid, nvme_get_ctrl(ctrl); - device_add_disk(ctrl->device, ns->disk, nvme_ns_id_attr_groups); + rc = device_add_disk(ctrl->device, ns->disk, nvme_ns_id_attr_groups); + if (rc) + goto out_cleanup_ns_from_list; + if (!nvme_ns_head_multipath(ns->head)) nvme_add_ns_cdev(ns); @@ -3785,6 +3789,10 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid, return; + out_cleanup_ns_from_list: + down_write(&ctrl->namespaces_rwsem); + list_del_init(&ns->list); + up_write(&ctrl->namespaces_rwsem); out_unlink_ns: mutex_lock(&ctrl->subsys->lock); list_del_rcu(&ns->siblings); From patchwork Mon Aug 23 20:29:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 501691 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 76AAEC4320A for ; Mon, 23 Aug 2021 20:30:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5CD4960E97 for ; Mon, 23 Aug 2021 20:30:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232344AbhHWUbL (ORCPT ); Mon, 23 Aug 2021 16:31:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232666AbhHWUaz (ORCPT ); Mon, 23 Aug 2021 16:30:55 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD444C061764; Mon, 23 Aug 2021 13:30:12 -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=e7rRtEm+k/UvglB8mkLZNHmTTdPjRwZAGNCpjle2wbI=; b=c2Vvmi8OhaKZfe1t6eRlDx2//+ ijrL3WWRkOpdOWip35YdrajKmu4R3cck3G01WY59I26MOGCS3TNzwZHW8JsW7zSLkUUPz7iYgFUDD MKXtK1/Xtb2phrfPafJL9wDteDqfLiV0T6Q5NSQQ+MgVYYmUwjgdDFAdZcXpn6lQqekefl+5VHU9I MKcSfXpK//ryiAMHNwYpEMLhDcyVwrtZ8OJG3B5dFwaNd7yCDksTm7ZUg97kPACpxpj4lfEp49hdC Oycb+X8ZT5b/dFJPCcvBdYF//BllWSZLrkCjHsvNXHDWpr2hMnSv3UxMzKpmjd3OTvqOV/vlSH52y yzyOWsow==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mIGZa-000ZjU-9o; Mon, 23 Aug 2021 20:29:34 +0000 From: Luis Chamberlain To: axboe@kernel.dk, martin.petersen@oracle.com, jejb@linux.ibm.com, kbusch@kernel.org, sagi@grimberg.me, adrian.hunter@intel.com, beanhuo@micron.com, ulf.hansson@linaro.org, avri.altman@wdc.com, swboyd@chromium.org, agk@redhat.com, snitzer@redhat.com, josef@toxicpanda.com Cc: hch@infradead.org, hare@suse.de, bvanassche@acm.org, ming.lei@redhat.com, linux-scsi@vger.kernel.org, linux-nvme@lists.infradead.org, linux-mmc@vger.kernel.org, dm-devel@redhat.com, nbd@other.debian.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Luis Chamberlain Subject: [PATCH 06/10] mmc/core/block: add error handling support for add_disk() Date: Mon, 23 Aug 2021 13:29:26 -0700 Message-Id: <20210823202930.137278-7-mcgrof@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210823202930.137278-1-mcgrof@kernel.org> References: <20210823202930.137278-1-mcgrof@kernel.org> MIME-Version: 1.0 Sender: Luis Chamberlain Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org We never checked for errors on add_disk() as this function returned void. Now that this is fixed, use the shiny new error handling. The caller cleanups the disk already so all we need to do is just pass along the return value. Signed-off-by: Luis Chamberlain --- drivers/mmc/core/block.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index 4c11f171e56d..4f12c6d1e1b5 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -2432,7 +2432,9 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card, /* used in ->open, must be set before add_disk: */ if (area_type == MMC_BLK_DATA_AREA_MAIN) dev_set_drvdata(&card->dev, md); - device_add_disk(md->parent, md->disk, mmc_disk_attr_groups); + ret = device_add_disk(md->parent, md->disk, mmc_disk_attr_groups); + if (ret) + goto out; return md; err_kfree: From patchwork Mon Aug 23 20:29:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 501690 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08325C19F33 for ; Mon, 23 Aug 2021 20:30:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E8B6C613A6 for ; Mon, 23 Aug 2021 20:30:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232682AbhHWUbU (ORCPT ); Mon, 23 Aug 2021 16:31:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232568AbhHWUa7 (ORCPT ); Mon, 23 Aug 2021 16:30:59 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C22DC06175F; Mon, 23 Aug 2021 13:30:16 -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=OfWwvKvXHF7mAR0YH9EVQI1Ai4xHJmlcz1fm4t+WkvQ=; b=c1NoizZM+bXC/4X0Kr/yu9qM/4 vogWc0nrHBCi45AdGqOBAij28BuUscFaMAFHbJ2yXQCp5OH9DacSlocg057cgyhEzAbp+eqUj9Zfh 6gWNmHJ2C2e/7/pq/RB+53totPFBi3AUR0PxzJLMVHEgo7uT0Z7UvGZdbbilsChDr2RBszTvYlsOb PELdLD+eJ6LkLyE4ocLD45dCwrtv3J3wf3TA8HC95Ydw3sT4gdo5pNlkSoYEw8a45/pSmg3NFnBWI GWZR46Bma5vyjALSf1nrc1KO1TqKtNpD5kmRJlERTgeNeRb6CWNyzFxwURUSlXc8oNnuujcl9QiQD if8hBZZA==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mIGZa-000ZjW-BM; Mon, 23 Aug 2021 20:29:34 +0000 From: Luis Chamberlain To: axboe@kernel.dk, martin.petersen@oracle.com, jejb@linux.ibm.com, kbusch@kernel.org, sagi@grimberg.me, adrian.hunter@intel.com, beanhuo@micron.com, ulf.hansson@linaro.org, avri.altman@wdc.com, swboyd@chromium.org, agk@redhat.com, snitzer@redhat.com, josef@toxicpanda.com Cc: hch@infradead.org, hare@suse.de, bvanassche@acm.org, ming.lei@redhat.com, linux-scsi@vger.kernel.org, linux-nvme@lists.infradead.org, linux-mmc@vger.kernel.org, dm-devel@redhat.com, nbd@other.debian.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Luis Chamberlain Subject: [PATCH 07/10] md: add error handling support for add_disk() Date: Mon, 23 Aug 2021 13:29:27 -0700 Message-Id: <20210823202930.137278-8-mcgrof@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210823202930.137278-1-mcgrof@kernel.org> References: <20210823202930.137278-1-mcgrof@kernel.org> MIME-Version: 1.0 Sender: Luis Chamberlain Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org We never checked for errors on add_disk() as this function returned void. Now that this is fixed, use the shiny new error handling. We just do the unwinding of what was not done before, and are sure to unlock prior to bailing. Signed-off-by: Luis Chamberlain Reviewed-by: Christoph Hellwig --- drivers/md/md.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/md/md.c b/drivers/md/md.c index ae8fe54ea358..5c0d3536d7c7 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -5704,7 +5704,11 @@ static int md_alloc(dev_t dev, char *name) * through to md_open, so make sure it doesn't get too far */ mutex_lock(&mddev->open_mutex); - add_disk(disk); + error = add_disk(disk); + if (error) { + blk_cleanup_disk(disk); + goto abort_unlock; + } error = kobject_add(&mddev->kobj, &disk_to_dev(disk)->kobj, "%s", "md"); if (error) { @@ -5718,6 +5722,7 @@ static int md_alloc(dev_t dev, char *name) if (mddev->kobj.sd && sysfs_create_group(&mddev->kobj, &md_bitmap_group)) pr_debug("pointless warning\n"); + abort_unlock: mutex_unlock(&mddev->open_mutex); abort: mutex_unlock(&disks_mutex);