Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp2574219pxb; Sun, 5 Sep 2021 23:51:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxdHNgttuubXQuydswGhO4elQAhjg7XYALpfIR0dE1CmkLetKHyzdC2k+tVpyfXn0T2eYSl X-Received: by 2002:a17:907:766e:: with SMTP id kk14mr12022156ejc.339.1630911061430; Sun, 05 Sep 2021 23:51:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630911061; cv=none; d=google.com; s=arc-20160816; b=KENOCw1HM7KqR1aFpAZSXduKQCblV/5v1PxBB0B9Aw4aRnS3aKdQV3cmkGGfAg6PGs APupLPJOhGnO9UUqbHGbqbqMsic7nlXVnjB54gVx7NzMLKoVgeiB0lyGSMI0/xNula/f fhwY2+T0iBIuMohr24gMxMt43YAN+9VfN7ZF+cOZ/xRx50aVZFI6BMuBvwlKhZl/qS2H KZUnu/PqsxmMAsQdhH2ae9a88O69Z96LHoLCQoQJBBT8eMjzcerzvEDAqLa5Fmm3af/N xP/ASvcxiw1W6kuHQ7N7kmgmh/ZNNpQnoEc7qTQKpV6B9qHN1EZxVbJOoS58Wpm42Avy AW6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature:dkim-signature; bh=Kg4Wg8l9Kk8kQXbHb+Zd/FuQr2WxF39YElxb+dyQ+VE=; b=eysyyvmMG6QraCA6LB0KM3RLnUvSiqIm9l/lAHCZQBIx/eIsZPP5rDHqo24NamMG5w 0iioqGSRLhtfJPhsIQ4Uyz9CfdlTKoP4+PpVq1LmJDcnnmhSrlkOGdvPnC1iKxJSmHfw dle96LOfqbiXAXCa0gPzisD28zDggPSALQdK7sbICM0vOydoQuqpM7WJ3pVZHGLsegKD qHLq9a9XTaus8zJf+imPNzZkdYPfF/MRvfkAw329m2yJnQkVNlCv/NAFcnKmvk6N0ost U3xeUhwiHuSD4rrDskG+9baMAhNv5VKWW2nD6KkUaAFB/GxmKyp+EGCRDY0+pzm3F+mB FBvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=jUKgUkat; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=KrMO6ehR; 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=suse.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v8si6801654ejv.188.2021.09.05.23.50.38; Sun, 05 Sep 2021 23:51:01 -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=@suse.de header.s=susede2_rsa header.b=jUKgUkat; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=KrMO6ehR; 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=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239398AbhIFGRl (ORCPT + 99 others); Mon, 6 Sep 2021 02:17:41 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:52046 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231271AbhIFGRk (ORCPT ); Mon, 6 Sep 2021 02:17:40 -0400 Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id B8DD32007F; Mon, 6 Sep 2021 06:16:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1630908994; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Kg4Wg8l9Kk8kQXbHb+Zd/FuQr2WxF39YElxb+dyQ+VE=; b=jUKgUkat+IWhWae9SRap4L0fOrkeAZYxNNu3dInXbGvI0NwGondgJOGBQ3nqMwT87HBvDx IiCWFhf0JbwgMc/IBcVoQrOD2wWgHtscQ49PVA/dZUyLxfE6EgXuAoeQbNEp7Mk/SzVzIn aB7KnTqlbofAItfphmfIvnFPK76BTF4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1630908994; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Kg4Wg8l9Kk8kQXbHb+Zd/FuQr2WxF39YElxb+dyQ+VE=; b=KrMO6ehR/K/zkDmPLkRvTxvqE5GVaXbGNecWPadjaqC3QuTyW1pJ2aFh5QHeu/H57K2JPF RApH1raAUiWxbPDw== Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap1.suse-dmz.suse.de (Postfix) with ESMTPS id B8ACF13299; Mon, 6 Sep 2021 06:16:33 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap1.suse-dmz.suse.de with ESMTPSA id lP1cKkGyNWFKTwAAGKfGzw (envelope-from ); Mon, 06 Sep 2021 06:16:33 +0000 Subject: Re: [PATCH v3 3/8] nvme: add error handling support for add_disk() To: Luis Chamberlain , 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, 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, Christoph Hellwig References: <20210830212538.148729-1-mcgrof@kernel.org> <20210830212538.148729-4-mcgrof@kernel.org> From: Hannes Reinecke Message-ID: <677ca876-b003-d3b5-9e2e-d50ebef82cce@suse.de> Date: Mon, 6 Sep 2021 08:16:35 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <20210830212538.148729-4-mcgrof@kernel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/30/21 11:25 PM, Luis Chamberlain wrote: > 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); > I would rather turn this around, and call 'nvme_put_ctrl()' after removing the namespace from the list. But it's probably more a style issue, come to think of it. Reviewed-by: Hannes Reinecke Cheers, Hannes -- Dr. Hannes Reinecke Kernel Storage Architect hare@suse.de +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer