Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp3938217pxb; Mon, 30 Aug 2021 14:30:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywHaxnFJOLFT82GRu9qSQ8Qx1cZopuiOdp/42e7cSO7L1gUhz6AF7WA3gZLQmCOlZ+BRzx X-Received: by 2002:a17:907:7f29:: with SMTP id qf41mr25366947ejc.211.1630359010035; Mon, 30 Aug 2021 14:30:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630359010; cv=none; d=google.com; s=arc-20160816; b=JkehsmaMe2pWOsDkJz0atTqwEVb7OfsmF7ShYMM7NLuLdp/7k517WML59eFzzytg9f 1NFvJyIa6E9OD1RKIBJ48mC84PDGUjWVMFQ36M8n8Og3IHx2XLXLkNbKyKyi+6sfaNiX MRHeLfgO6IUx46C76HGQiE4Pa0MeWR9Ia+p6WNeJmlDJPj3g6MxdV0KBHGvfsvqM+Pwm 1odmwJaJ2Vhzz2/ARjoBaQrJ5jgMmMym0OmQU8IjuL8GYt3wXc1TLLpkgR+cMn1AydBq jC2FL2K7mPZjToYTTM4IdauKEo+v3DsjvYM+oh7dS6s5ztuEg5w0XGBmOmojFkWIjdEk i8jA== 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=WZDOVyRqrotfblM3MrNHqoihizZi1dQWZqaOZFp5Q1M=; b=Gt04urTds6A53F2JcNVbu74GLPltW8qq9vHGIsCsNP1Sme69NKjw6KOW1FKokoUKpS pu7inN/2I4mgGMMmss6hA8rYcebvHWsVUwgCmmhUJPDjaI+MXClaY49eTZuKi4CRgj8d GrtRSak6RoLAu+5ysE3Qliv1l5rn+aRje+2DuQBdwIrVHFSGyAvzFRujv7iM3k/WZ86q DzEYZID2JTCYu3wr7j6ozNbtm/H7kvvThPE2mPfT88CEkx6GTt/d3ewEbRsVroIi3zoX dQkz5/H/imS82kNuChA/n3CIcTQ3OMkFHLTF3+0exe6r7WG3wBKITiTGrXiW2pBRmxHE EFKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b="i8ELcjA/"; 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 et19si6317080ejc.659.2021.08.30.14.29.46; Mon, 30 Aug 2021 14:30:10 -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="i8ELcjA/"; 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 S238606AbhH3V1b (ORCPT + 99 others); Mon, 30 Aug 2021 17:27:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230255AbhH3V1F (ORCPT ); Mon, 30 Aug 2021 17:27:05 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56461C061760; Mon, 30 Aug 2021 14:26: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=WZDOVyRqrotfblM3MrNHqoihizZi1dQWZqaOZFp5Q1M=; b=i8ELcjA/anrU1TOHpT3BXlv5sQ 9q5jw+XOVVb/qUvV9ig0gbEr9CrSUmV3KpTOZDXHGFakrCIS18jy03q+1JzG3IWwARLfGn1Z/7fo/ XOcVbLQBZElwJbcert/XSMBhSrXd977VdHJk+2AXpHpLvWfDd6FWkkd+Ie9d+lv89upJrOWSbAJSK nT0oSWfCoTlrFojFLLJ3zXxMvwbM0j0ElnF6FO/lzdjKqXXgHhhs3sE1xiVRyqkLqBTwNloi2o17C S6tz5a9SINyP3qxdan7AtdeT2cf48qweDik29nXili4ONS2xfgWdyOpQF8Qksp4ZnyNcDGVKJS1LK 1iirUqCg==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mKomk-000ciA-Km; Mon, 30 Aug 2021 21:25:42 +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 , Christoph Hellwig Subject: [PATCH v3 3/8] nvme: add error handling support for add_disk() Date: Mon, 30 Aug 2021 14:25:33 -0700 Message-Id: <20210830212538.148729-4-mcgrof@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210830212538.148729-1-mcgrof@kernel.org> References: <20210830212538.148729-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 We never checked for errors on add_disk() as this function returned void. Now that this is fixed, use the shiny new error handling. Reviewed-by: Christoph Hellwig Signed-off-by: Luis Chamberlain --- drivers/nvme/host/core.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 8679a108f571..687d3be563a3 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -3763,7 +3763,9 @@ 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); + if (device_add_disk(ctrl->device, ns->disk, nvme_ns_id_attr_groups)) + goto out_cleanup_ns_from_list; + if (!nvme_ns_head_multipath(ns->head)) nvme_add_ns_cdev(ns); @@ -3773,6 +3775,11 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid, return; + out_cleanup_ns_from_list: + nvme_put_ctrl(ctrl); + 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); -- 2.30.2